@dropins/storefront-auth 4.0.1 → 4.0.2-alpha-20260901202918
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.
- package/CHANGELOG.md +97 -27
- package/chunks/components.js +1 -1
- package/chunks/components.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
- package/render.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,59 @@
|
|
|
1
1
|
# @dropins/storefront-auth
|
|
2
2
|
|
|
3
|
+
## 4.0.2-alpha-20260901202918
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 050f562: Adds AGENTS.md file used for guidance for AI coding agents
|
|
8
|
+
- d86b5f6: Fix the "Loading" state on sign in, sign up, forgot password and
|
|
9
|
+
update password submit buttons not being announced by screen readers. The
|
|
10
|
+
button now exposes `aria-busy` and a persistent, visually-hidden live region
|
|
11
|
+
announces the loading status instead of it being missed when the visual
|
|
12
|
+
spinner mounts and unmounts (WCAG 4.1.3).
|
|
13
|
+
|
|
3
14
|
## 4.0.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
|
7
18
|
- 0a4341a: Bump SDK stable versions
|
|
8
|
-
- 857e7aa: Fix visual heading text not marked as heading across sign in, sign
|
|
19
|
+
- 857e7aa: Fix visual heading text not marked as heading across sign in, sign
|
|
20
|
+
up, reset password and update password forms
|
|
9
21
|
- 5b8e0df: Fix incorrect and missing `autocomplete` attributes on form fields.
|
|
10
22
|
|
|
11
|
-
The email field on sign in, sign in popover, forgot password, and create
|
|
23
|
+
The email field on sign in, sign in popover, forgot password, and create
|
|
24
|
+
account previously used `autocomplete="username"`, which does not tell
|
|
25
|
+
browsers and password managers the field expects an email address. It now uses
|
|
26
|
+
`autocomplete="email"`.
|
|
12
27
|
|
|
13
|
-
The first name and last name fields on create account were missing an
|
|
28
|
+
The first name and last name fields on create account were missing an
|
|
29
|
+
`autocomplete` attribute entirely; they now use `given-name` and `family-name`
|
|
30
|
+
respectively.
|
|
14
31
|
|
|
15
|
-
The password and confirm password fields on the sign up form used
|
|
32
|
+
The password and confirm password fields on the sign up form used
|
|
33
|
+
incorrect/invalid `autocomplete` values (`current-password` and
|
|
34
|
+
`confirmPassword`, the latter not a valid HTML5 token). Both now use
|
|
35
|
+
`new-password`, the correct value for a field that sets a new password.
|
|
16
36
|
|
|
17
|
-
This helps browsers and assistive technology correctly identify the purpose of
|
|
37
|
+
This helps browsers and assistive technology correctly identify the purpose of
|
|
38
|
+
each field, making autofill and form-filling easier for everyone, including
|
|
39
|
+
people using screen readers or who have difficulty typing.
|
|
18
40
|
|
|
19
41
|
- 57f64d7: Fix VALIDATE_TOKEN query incompatibility with ACCS.
|
|
20
42
|
|
|
21
|
-
The token validation query previously included `customer { group { uid } }`, a
|
|
43
|
+
The token validation query previously included `customer { group { uid } }`, a
|
|
44
|
+
field not available in ACCS backends, causing a schema error during drop-in
|
|
45
|
+
initialization.
|
|
22
46
|
|
|
23
47
|
The query is now split into two variants:
|
|
24
48
|
|
|
25
49
|
- A minimal ACCS-compatible query used by default
|
|
26
|
-
- A query that includes `group { uid }` for Adobe Commerce Optimizer (ACO)
|
|
50
|
+
- A query that includes `group { uid }` for Adobe Commerce Optimizer (ACO)
|
|
51
|
+
price book resolution, used only when `adobeCommerceOptimizer: true` is set
|
|
52
|
+
in the init config
|
|
27
53
|
|
|
28
|
-
No changes are required for existing implementations. Merchants not using ACO
|
|
54
|
+
No changes are required for existing implementations. Merchants not using ACO
|
|
55
|
+
are unaffected. Merchants using ACO continue to receive the `auth/group-uid`
|
|
56
|
+
event as before.
|
|
29
57
|
|
|
30
58
|
## 4.0.1-beta.1
|
|
31
59
|
|
|
@@ -37,46 +65,74 @@
|
|
|
37
65
|
|
|
38
66
|
### Patch Changes
|
|
39
67
|
|
|
40
|
-
- 857e7aa: Fix visual heading text not marked as heading across sign in, sign
|
|
68
|
+
- 857e7aa: Fix visual heading text not marked as heading across sign in, sign
|
|
69
|
+
up, reset password and update password forms
|
|
41
70
|
- 5b8e0df: Fix incorrect and missing `autocomplete` attributes on form fields.
|
|
42
71
|
|
|
43
|
-
The email field on sign in, sign in popover, forgot password, and create
|
|
72
|
+
The email field on sign in, sign in popover, forgot password, and create
|
|
73
|
+
account previously used `autocomplete="username"`, which does not tell
|
|
74
|
+
browsers and password managers the field expects an email address. It now uses
|
|
75
|
+
`autocomplete="email"`.
|
|
44
76
|
|
|
45
|
-
The first name and last name fields on create account were missing an
|
|
77
|
+
The first name and last name fields on create account were missing an
|
|
78
|
+
`autocomplete` attribute entirely; they now use `given-name` and `family-name`
|
|
79
|
+
respectively.
|
|
46
80
|
|
|
47
|
-
The password and confirm password fields on the sign up form used
|
|
81
|
+
The password and confirm password fields on the sign up form used
|
|
82
|
+
incorrect/invalid `autocomplete` values (`current-password` and
|
|
83
|
+
`confirmPassword`, the latter not a valid HTML5 token). Both now use
|
|
84
|
+
`new-password`, the correct value for a field that sets a new password.
|
|
48
85
|
|
|
49
|
-
This helps browsers and assistive technology correctly identify the purpose of
|
|
86
|
+
This helps browsers and assistive technology correctly identify the purpose of
|
|
87
|
+
each field, making autofill and form-filling easier for everyone, including
|
|
88
|
+
people using screen readers or who have difficulty typing.
|
|
50
89
|
|
|
51
90
|
- 57f64d7: Fix VALIDATE_TOKEN query incompatibility with ACCS.
|
|
52
91
|
|
|
53
|
-
The token validation query previously included `customer { group { uid } }`, a
|
|
92
|
+
The token validation query previously included `customer { group { uid } }`, a
|
|
93
|
+
field not available in ACCS backends, causing a schema error during drop-in
|
|
94
|
+
initialization.
|
|
54
95
|
|
|
55
96
|
The query is now split into two variants:
|
|
56
97
|
|
|
57
98
|
- A minimal ACCS-compatible query used by default
|
|
58
|
-
- A query that includes `group { uid }` for Adobe Commerce Optimizer (ACO)
|
|
99
|
+
- A query that includes `group { uid }` for Adobe Commerce Optimizer (ACO)
|
|
100
|
+
price book resolution, used only when `adobeCommerceOptimizer: true` is set
|
|
101
|
+
in the init config
|
|
59
102
|
|
|
60
|
-
No changes are required for existing implementations. Merchants not using ACO
|
|
103
|
+
No changes are required for existing implementations. Merchants not using ACO
|
|
104
|
+
are unaffected. Merchants using ACO continue to receive the `auth/group-uid`
|
|
105
|
+
event as before.
|
|
61
106
|
|
|
62
107
|
## 4.0.0
|
|
63
108
|
|
|
64
109
|
### Major Changes
|
|
65
110
|
|
|
66
|
-
- 515ce05: Add support for Remote Shopping Assistance feature that enables store
|
|
111
|
+
- 515ce05: Add support for Remote Shopping Assistance feature that enables store
|
|
112
|
+
administrators to help customers with purchases. The implementation includes
|
|
113
|
+
admin session management via JWT token validation, a consent UI component for
|
|
114
|
+
customer approval, and enhanced cookie security with proper encoding and
|
|
115
|
+
SameSite protection for all authentication cookies
|
|
67
116
|
|
|
68
117
|
### Minor Changes
|
|
69
118
|
|
|
70
119
|
- f208291: Upgraded Elsie package to use the 1.9.0-beta.0 version
|
|
71
120
|
- f208291: Migrate to Node.js 24 LTS
|
|
72
121
|
|
|
73
|
-
Minimum required Node.js version is now 24. Updated engines.node from >=20
|
|
122
|
+
Minimum required Node.js version is now 24. Updated engines.node from >=20
|
|
123
|
+
to >=24.
|
|
74
124
|
|
|
75
|
-
- 572b81a: Removed the `engines.node` constraint from `package.json`. This
|
|
125
|
+
- 572b81a: Removed the `engines.node` constraint from `package.json`. This
|
|
126
|
+
package targets browser environments exclusively and does not depend on a
|
|
127
|
+
specific Node.js runtime version. The package is now built and distributed
|
|
128
|
+
using Node.js 22 LTS.
|
|
76
129
|
|
|
77
130
|
### Patch Changes
|
|
78
131
|
|
|
79
|
-
- f208291: Ensure `getCustomerRolePermissions` always emits `auth/permissions`
|
|
132
|
+
- f208291: Ensure `getCustomerRolePermissions` always emits `auth/permissions`
|
|
133
|
+
so consumers (e.g. account navigation) keep working. For non-admin customers
|
|
134
|
+
with no granular ACL tree from GraphQL, set `Magento_Sales::place_order` so
|
|
135
|
+
storefront checkout does not treat B2C users as denied.
|
|
80
136
|
- 2870239: Bump to StorefrontSDK stable version
|
|
81
137
|
- 1c0576b: Bump @adobe-commerce/elsie to v1.9.0-beta.3
|
|
82
138
|
|
|
@@ -96,13 +152,20 @@
|
|
|
96
152
|
|
|
97
153
|
### Major Changes
|
|
98
154
|
|
|
99
|
-
- 515ce05: Add support for Remote Shopping Assistance feature that enables store
|
|
155
|
+
- 515ce05: Add support for Remote Shopping Assistance feature that enables store
|
|
156
|
+
administrators to help customers with purchases. The implementation includes
|
|
157
|
+
admin session management via JWT token validation, a consent UI component for
|
|
158
|
+
customer approval, and enhanced cookie security with proper encoding and
|
|
159
|
+
SameSite protection for all authentication cookies
|
|
100
160
|
|
|
101
161
|
## 3.3.0-beta.2
|
|
102
162
|
|
|
103
163
|
### Minor Changes
|
|
104
164
|
|
|
105
|
-
- 572b81a: Removed the `engines.node` constraint from `package.json`. This
|
|
165
|
+
- 572b81a: Removed the `engines.node` constraint from `package.json`. This
|
|
166
|
+
package targets browser environments exclusively and does not depend on a
|
|
167
|
+
specific Node.js runtime version. The package is now built and distributed
|
|
168
|
+
using Node.js 22 LTS.
|
|
106
169
|
|
|
107
170
|
## 3.3.0-beta.1
|
|
108
171
|
|
|
@@ -114,18 +177,23 @@
|
|
|
114
177
|
|
|
115
178
|
### Patch Changes
|
|
116
179
|
|
|
117
|
-
- 3cadf48: Ensure `getCustomerRolePermissions` always emits `auth/permissions`
|
|
180
|
+
- 3cadf48: Ensure `getCustomerRolePermissions` always emits `auth/permissions`
|
|
181
|
+
so consumers (e.g. account navigation) keep working. For non-admin customers
|
|
182
|
+
with no granular ACL tree from GraphQL, set `Magento_Sales::place_order` so
|
|
183
|
+
storefront checkout does not treat B2C users as denied.
|
|
118
184
|
|
|
119
185
|
## 3.2.0
|
|
120
186
|
|
|
121
187
|
### Minor Changes
|
|
122
188
|
|
|
123
189
|
- e880d43: Adds missing slot props to the Reset Password Container.
|
|
124
|
-
- 901ad98: Introduced slots for Title, Form and Buttons sections in all
|
|
190
|
+
- 901ad98: Introduced slots for Title, Form and Buttons sections in all
|
|
191
|
+
containers to enhance flexibility and customization
|
|
125
192
|
|
|
126
193
|
### Patch Changes
|
|
127
194
|
|
|
128
|
-
- 323dd52: Add Changesets-based release automation with branch-aware workflows
|
|
195
|
+
- 323dd52: Add Changesets-based release automation with branch-aware workflows
|
|
196
|
+
(alpha/beta/stable), PR changeset validation, and contributor helper scripts.
|
|
129
197
|
- fc20311: Bump "@adobe-commerce/elsie" from 1.7.0 to 1.8.0
|
|
130
198
|
|
|
131
199
|
## 3.2.0-beta.1
|
|
@@ -139,8 +207,10 @@
|
|
|
139
207
|
### Minor Changes
|
|
140
208
|
|
|
141
209
|
- e880d43: Adds missing slot props to the Reset Password Container.
|
|
142
|
-
- 901ad98: Introduced slots for Title, Form and Buttons sections in all
|
|
210
|
+
- 901ad98: Introduced slots for Title, Form and Buttons sections in all
|
|
211
|
+
containers to enhance flexibility and customization
|
|
143
212
|
|
|
144
213
|
### Patch Changes
|
|
145
214
|
|
|
146
|
-
- 323dd52: Add Changesets-based release automation with branch-aware workflows
|
|
215
|
+
- 323dd52: Add Changesets-based release automation with branch-aware workflows
|
|
216
|
+
(alpha/beta/stable), PR changeset validation, and contributor helper scripts.
|
package/chunks/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as R,jsx as o,Fragment as Ae}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as xe,useState as x,useCallback as F,useEffect as ie,useRef as De}from"@dropins/tools/preact-hooks.js";import{classes as re,Slot as D}from"@dropins/tools/lib.js";import{useText as J}from"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import{initReCaptcha as nt}from"@dropins/tools/recaptcha.js";import{Skeleton as Le,SkeletonRow as U,InLineAlert as fe,Header as ge,InputPassword as Te,Button as Pe,Field as Re,Checkbox as Se,Input as ot,Picker as st,InputDate as it,TextArea as ut}from"@dropins/tools/components.js";import*as z from"@dropins/tools/preact-compat.js";import{memo as de}from"@dropins/tools/preact-compat.js";import{resendConfirmationEmail as Ze,getStoreConfig as ct,resetPassword as lt,getCustomerToken as Ie,revokeCustomerToken as dt,t as mt,getAttributesForm as ht,c as ft,createCustomer as gt,p as pt,E as _t,createCustomerAddress as Et,confirmEmail as Tt,requestPasswordResetEmail as Nt}from"../api.js";const At=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),xt=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),wt=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),yt=({activeSkeleton:e})=>{const t=xe(()=>({signInForm:o(xt,{}),signUpForm:o(At,{}),resetPasswordForm:o(wt,{})}),[]);return o(Ae,{children:t[e]})},bt=({userEmail:e,handleSetInLineAlertProps:t})=>{const r=J({emailConfirmationMessage:"Auth.Notification.emailConfirmationMessage",technicalErrorSendEmail:"Auth.Notification.technicalErrors.technicalErrorSendEmail"}),[a,s]=x(!1);return{handleEmailConfirmation:F(async()=>{var u,i;if(s(!0),e){const c=await Ze(e);if(c){const m=(u=c==null?void 0:c.errors)==null?void 0:u.length,l=(i=c==null?void 0:c.data)==null?void 0:i.resendConfirmationEmail;t(m?{type:"error",text:r.technicalErrorSendEmail}:{type:l?"success":"error",text:r.emailConfirmationMessage})}}s(!1)},[t,r,e]),disabledButton:a}},Xe=({formSize:e,userEmail:t,inLineAlertProps:r,hideCloseBtnOnEmailConfirmation:a,handleSetInLineAlertProps:s,onPrimaryButtonClick:n})=>{const u=J({title:"Auth.EmailConfirmationForm.title",subtitle:"Auth.EmailConfirmationForm.subtitle",mainText:"Auth.EmailConfirmationForm.mainText",buttonPrimary:"Auth.EmailConfirmationForm.buttonPrimary",buttonSecondary:"Auth.EmailConfirmationForm.buttonSecondary"}),{handleEmailConfirmation:i,disabledButton:c}=bt({userEmail:t,handleSetInLineAlertProps:s});return R("div",{className:re(["auth-email-confirmation-form",`auth-email-confirmation-form--${e}`]),children:[r.text?o(fe,{className:"auth-signInForm__notification",type:r.type,variant:"secondary",heading:r.text,icon:r.icon,"data-testid":"authInLineAlert"}):null,o(ge,{title:u.title,divider:!1,className:"auth-email-confirmation-form__title"}),t!=null&&t.length?o("span",{className:"auth-email-confirmation-form__subtitle",children:`${u.subtitle} ${t}`}):null,o("span",{className:"auth-email-confirmation-form__text",children:u.mainText}),R("div",{className:"auth-email-confirmation-form__buttons",children:[o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:u.buttonSecondary,enableLoader:!1,onClick:i,disabled:c}),a?null:o(te,{type:"submit",buttonText:u.buttonPrimary,variant:"primary",enableLoader:!1,disabled:c,onClick:n})]})]})},Ke=()=>{const[e,t]=x(!1),[r,a]=x(null),[s,n]=x(null),u=i=>{const{minLength:c,requiredCharacterClasses:m,createAccountConfirmation:l,shoppingAssistanceEnabled:A,shoppingAssistanceCheckboxTitle:_,shoppingAssistanceCheckboxTooltip:w}=i;a({minLength:c,requiredCharacterClasses:m}),t(l),n({shoppingAssistanceEnabled:A,shoppingAssistanceCheckboxTitle:_,shoppingAssistanceCheckboxTooltip:w})};return ie(()=>{const i=sessionStorage.getItem("storeConfig");let c=null;try{c=i?JSON.parse(i):null}catch{c=null}if(c){u(c);return}ct().then(m=>{m&&(sessionStorage.setItem("storeConfig",JSON.stringify(m)),u(m))})},[]),{passwordConfigs:r,isEmailConfirmationRequired:e,remoteShoppingAssistanceConfigs:s}},Ue=(e,t)=>{if(t<=1)return!0;const r=/[0-9]/.test(e)?1:0,a=/[a-z]/.test(e)?1:0,s=/[A-Z]/.test(e)?1:0,n=/[^a-zA-Z0-9\s]/.test(e)?1:0;return r+a+s+n>=t},Je=({passwordConfigs:e,isClickSubmit:t,password:r})=>{const a=J({messageLengthPassword:"Auth.PasswordValidationMessage.messageLengthPassword"}),[s,n]=x("pending");ie(()=>{if(!e)return;const i=Ue(r,e.requiredCharacterClasses);t&&r.length>0?n(i?"success":"error"):t&&r.length===0?n("pending"):n(i?"success":"pending")},[t,e,r]);const u=xe(()=>{var c;if(!e)return;const i={status:"pending",icon:"pending",message:(c=a.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return r.length&&r.length>=e.minLength?{...i,icon:"success",status:"success"}:r.length&&r.length<e.minLength?t?{...i,icon:"error",status:"error"}:{...i,icon:"pending",status:"pending"}:i},[e,a.messageLengthPassword,r==null?void 0:r.length,t]);return{isValidUniqueSymbols:s,defaultLengthMessage:u}},we=e=>{if(!e)return null;const t=new FormData(e);if(t&&typeof t.entries=="function"){const r=t.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},ke=(e,t)=>e.split("&").filter(a=>a.includes(t)).map(a=>a.split("=")[1])[0],q=e=>typeof e=="function",j=e=>{window.location.href=e},Ft=({isEmailConfirmationRequired:e,signInOnSuccess:t,passwordConfigs:r,routeRedirectOnSignIn:a,routeWrongUrlRedirect:s,onErrorCallback:n,onSuccessCallback:u,handleSetInLineAlertProps:i,routeRedirectOnPasswordUpdate:c,routeSignInPage:m})=>{const l=J({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[A,_]=x({userName:"",status:!1}),[w,h]=x(""),[f,d]=x(!1),[T,y]=x(""),[g,N]=x(""),[E,p]=x(!1),[b,S]=x(!1),[$,v]=x([]);ie(()=>{f&&!$.length&&(w.length?S(!1):S(!0))},[f,w,$]),ie(()=>{const{search:B}=window.location;!B.includes("token=")&&!B.includes("email=")&&q(s)&&j(s());const L=decodeURIComponent(B),O=ke(L,"token"),G=ke(L,"email");y(G),N(O)},[s]);const C=F(async B=>{B.preventDefault(),p(!0),v([]);const L=we(B.target),O=(L==null?void 0:L.password)&&T&&g;L!=null&&L.password||(S(!0),p(!1));const G=(r==null?void 0:r.requiredCharacterClasses)??0,ae=(r==null?void 0:r.minLength)??0;if(!Ue(L==null?void 0:L.password,G)||L.password.length<+ae){d(!0),p(!1);return}if(!O){i({type:"error",text:l.errorNotification}),p(!1);return}const{message:Z,success:ne}=await lt(T,g,L.password);if(ne){if(e||!e&&!t){u==null||u(),q(c)&&j(c()),d(!0),p(!1),S(!1),h(""),v([{label:l.updatePasswordActionMessage,onClick:()=>{j(m==null?void 0:m())}}]),i({type:"success",text:l.updatePasswordMessage});return}const k=await Ie({email:T,password:L.password,handleSetInLineAlertProps:i,onErrorCallback:n,translations:l});k!=null&&k.userName&&(u==null||u(k==null?void 0:k.userName),q(a)?j(a()):_({userName:k==null?void 0:k.userName,status:!0}))}else i({type:"error",text:Z}),n==null||n({message:Z,success:ne});p(!1)},[T,g,r==null?void 0:r.requiredCharacterClasses,r==null?void 0:r.minLength,l,e,t,m,n,u,a,i,c]),Y=F(B=>{h(B)},[]);return{additionalActionsAlert:$,passwordError:b,isSuccessful:A,updatePasswordValue:w,isClickSubmit:f,isLoading:E,submitUpdatePassword:C,handleSetUpdatePasswordValue:Y,setIsClickSubmit:d}},vt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Pt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round"})),Mt=e=>z.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("g",{clipPath:"url(#clip0_841_1324)"},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),z.createElement("defs",null,z.createElement("clipPath",{id:"clip0_841_1324"},z.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),Lt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Rt={success:o(vt,{}),warning:o(Mt,{}),error:o(Lt,{})},ye=()=>{const[e,t]=x({}),r=F(a=>{if(!a||!a.type){t({});return}const s=Rt[a.type];t({...a,icon:s})},[]);return{inLineAlertProps:e,handleSetInLineAlertProps:r}};var H=(e=>(e.REQUIRED_FIELD_ERROR="requiredFieldError",e.NUMERIC_ERROR="numericError",e.ALPHA_NUM_WITH_SPACES_ERROR="alphaNumWithSpacesError",e.ALPHA_NUMERIC_ERROR="alphaNumericError",e.ALPHA_ERROR="alphaError",e.EMAIL_ERROR="emailError",e.DATE_ERROR="dateError",e.DATE_RANGE_ERROR="dateRangeError",e.DATE_MAX_ERROR="dateMaxError",e.DATE_MIN_ERROR="dateMinError",e.URL_ERROR="urlError",e.LENGTH_TEXT_ERROR="lengthTextError",e))(H||{});const V="/",be=e=>{const t=J(e),r=Object.entries(t).filter(([n,u])=>u===null&&Object.values(H).includes(n)).map(([n])=>n),a=r.reduce((n,u)=>(n[u]=`Auth.FormText.${u}`,n),{}),s=J(a);return{...t,...r.reduce((n,u)=>(n[u]=s[u],n),{})}},fr=({signInOnSuccess:e=!0,formSize:t="default",routeRedirectOnSignIn:r,routeWrongUrlRedirect:a,routeSignInPage:s,slots:n,onErrorCallback:u,onSuccessCallback:i,routeRedirectOnPasswordUpdate:c})=>{const m=be({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{passwordConfigs:l,isEmailConfirmationRequired:A}=Ke(),{inLineAlertProps:_,handleSetInLineAlertProps:w}=ye(),{additionalActionsAlert:h,passwordError:f,isSuccessful:d,updatePasswordValue:T,isClickSubmit:y,isLoading:g,submitUpdatePassword:N,handleSetUpdatePasswordValue:E}=Ft({isEmailConfirmationRequired:A,signInOnSuccess:e,passwordConfigs:l,routeRedirectOnSignIn:r,routeWrongUrlRedirect:a,onErrorCallback:u,onSuccessCallback:i,handleSetInLineAlertProps:w,routeRedirectOnPasswordUpdate:c,routeSignInPage:s}),{isValidUniqueSymbols:p,defaultLengthMessage:b}=Je({password:T,isClickSubmit:y,passwordConfigs:l});if(d.status&&(n!=null&&n.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:n==null?void 0:n.SuccessNotification,context:{isSuccessful:d}});const S={updatePasswordValue:T,isLoading:g,passwordError:f,isSuccessful:d};return R("div",{className:re(["auth-update-password-form",`auth-update-password-form--${t}`]),children:[o(D,{name:"Title","data-testid":"title",slot:n==null?void 0:n.Title,context:{...S},children:o(ge,{title:m.title,divider:!1,className:"auth-update-password-form__title",level:1})}),o(fe,{className:re(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(_!=null&&_.text)]]),variant:"secondary",heading:_==null?void 0:_.text,icon:_.icon,additionalActions:h}),R(Fe,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:N,loading:g,fieldsConfig:[],formSlot:{name:"Form",slot:n==null?void 0:n.Form,context:S,dataTestId:"form"},children:[o("div",{style:"display: none;",children:o("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),o(Te,{defaultValue:T,onValue:E,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:f||p==="error"||(b==null?void 0:b.status)==="error"?m.requiredFieldError:void 0,minLength:l==null?void 0:l.minLength,uniqueSymbolsStatus:p,validateLengthConfig:b,requiredCharacterClasses:l==null?void 0:l.requiredCharacterClasses,placeholder:m.placeholder,floatingLabel:m.floatingLabel}),o(D,{name:"Buttons",className:"auth-update-password-form__button","data-testid":"buttons",slot:n==null?void 0:n.Buttons,context:{...S},children:o(te,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:g})})]})]})},gr=({formSize:e="default",className:t="",slots:r,labels:a})=>{const s=J({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return R("div",{className:re(["auth-success-notification-form",`auth-success-notification-form--${e}`,t]),id:"welcome-message",role:"alert","aria-live":"assertive","aria-labelledby":(a==null?void 0:a.headingText)??s.headingText,"aria-describedby":(a==null?void 0:a.messageText)??s.messageText,"tab-index":"-1",children:[o("p",{id:"welcome-heading",className:"auth-success-notification-form__title","data-testid":"notification-title",children:(a==null?void 0:a.headingText)??s.headingText}),o("p",{id:"welcome-details",className:"auth-success-notification-form__content-text","data-testid":"notification-content",children:(a==null?void 0:a.messageText)??s.messageText}),r!=null&&r.SuccessNotificationActions?o(D,{"data-testid":"successNotificationActions",name:"SuccessNotificationActions",slot:r==null?void 0:r.SuccessNotificationActions,context:{}}):R(Ae,{children:[o(Pe,{"data-testid":"primaryButton",type:"button",className:"auth-success-notification-form__button auth-success-notification-form__button--top",onClick:()=>j("/"),children:s.primaryButtonText}),o(Pe,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await dt(),j("/")},children:s.secondaryButtonText})]})]})},St=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-sign-in-form__form__email",frontend_input:"TEXT",is_required:!0,multiline_count:1,sort_order:1,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"}],It=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-reset-password-form__form__item",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"}],Ut=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",multiline_count:1,sort_order:1,options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"},{customUpperCode:"firstname",code:"firstname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"First name",multiline_count:1,sort_order:2,options:[],autocomplete:"given-name"},{customUpperCode:"lastname",code:"lastname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!1,is_unique:!1,label:"Last name",multiline_count:1,sort_order:3,options:[],autocomplete:"family-name"}],Ne=e=>e!=null&&e.length?mt({data:{attributesForm:{items:e}}}):[],We=(e,t)=>t!=null&&t.length?e.map(r=>{var s;const a=(s=t.find(({code:n})=>n===r.code))==null?void 0:s.defaultValue;return a?{...r,defaultValue:a}:r}):e,Ct=({inputsDefaultValueSet:e,fieldsConfigForApiVersion1:t,apiVersion2:r})=>{const[a,s]=x([]);return ie(()=>{(async()=>{if(r){const u=await ht("customer_account_create");if(u!=null&&u.length)if(e!=null&&e.length){const i=We(u,e);s(i)}else s(u)}else{const u=Ne(Ut),i=Ne(t),c=We(u,e);s(t&&t.length?i:c)}})()},[r,t,e]),{fieldsListConfigs:a.map(n=>({...n,...n.code==="email"?{autocomplete:"email"}:{}}))}},$t=(e,t)=>{const r=["dob","email","firstname","gender","lastname","middlename","password","prefix","suffix","taxvat","allow_remote_shopping_assistance"],a=ft(e,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!t)return{...a,...a!=null&&a.gender?{gender:Number(a==null?void 0:a.gender)}:{}};const s={},n=[];return Object.keys(a).forEach(u=>{r.includes(u)?u.includes("gender")?s[u]=Number(a[u]):u==="allow_remote_shopping_assistance"?s[u]=a[u]==="true":s[u]=a[u]:n.push({attribute_code:u,value:a[u]})}),n.length>0&&(s.custom_attributes=n),s},Me=(e,t,r)=>{const a=e.target.querySelector('input[name="password"]'),s=e.target.querySelector('input[name="confirmPasswordField"]');a&&!t.length?a.focus():s&&!r.length&&s.focus()},Ot=({requireRetypePassword:e,addressesData:t,translations:r,isEmailConfirmationRequired:a,apiVersion2:s=!0,passwordConfigs:n,isAutoSignInEnabled:u,routeRedirectOnSignIn:i,routeSignIn:c,onErrorCallback:m,onSuccessCallback:l,setActiveComponent:A,handleSetInLineAlertProps:_,routeRedirectOnEmailConfirmationClose:w})=>{const[h,f]=x(!1),[d,T]=x(""),[y,g]=x(""),[N,E]=x(""),[p,b]=x(!1),[S,$]=x({userName:"",status:!1}),[v,C]=x(""),[Y,B]=x(!1),[L,O]=x(!1),[G,ae]=x(!0),Z=F(M=>{const X=M.target.value;f(!X.length),X.length&&d.length&&X!==d&&g(r.passwordMismatch)},[d,r.passwordMismatch]),ne=F(M=>{const X=M.target.value;g(X.length?"":r.requiredFieldError),X.length&&v.length&&X!==v&&g(r.passwordMismatch)},[v,r.passwordMismatch,r.requiredFieldError]),k=F(M=>{T(M),g(M?v===M?"":r.passwordMismatch:r.requiredFieldError)},[r,v]),me=F(({target:M})=>{ae(M.checked)},[]),P=F(()=>{if(q(A)){A("signInForm");return}q(c)&&j(c())},[A,c]),I=F(M=>{C(M),f(!M.length),M===d&&g("")},[d]),Q=F(()=>{_(),C(""),q(w)?j(w()):(b(!1),A==null||A("signInForm"))},[_,w,A]),W=()=>{B(!0),O(!1)},ee=(M,X)=>{const Ce=v.length&&d.length,he=v!==d,oe=()=>{f(!v.length),d||g(r.requiredFieldError),Ce&&he&&g(r.passwordMismatch)},ue=()=>{g(d.length?r.passwordMismatch:r.requiredFieldError),Me(M,v,d)};return X?e&&(y.length||he)?(W(),ue(),!0):(Me(M,v,""),oe(),!1):(W(),oe(),!0)};return{showPasswordErrorMessage:h,confirmPassword:d,confirmPasswordMessage:y,isKeepMeLogged:G,userEmail:N,showEmailConfirmationForm:p,isSuccessful:S,isClickSubmit:Y,signUpPasswordValue:v,isLoading:L,onSubmitSignUp:async(M,X)=>{var $e,Oe,Be;if(_(),g(""),O(!0),ee(M,X))return;const{confirmPasswordField:Ce,...he}=we(M.target),{email:oe,password:ue}=he,et=(n==null?void 0:n.requiredCharacterClasses)||0,tt=(n==null?void 0:n.minLength)||1;if(!Ue(ue,et)||tt>(ue==null?void 0:ue.length)){W();return}const rt=$t({...he},s),se=await gt(rt,s);if(($e=se==null?void 0:se.errors)!=null&&$e.length){const{errors:ce}=se;_==null||_({type:"error",text:(Oe=ce[0])==null?void 0:Oe.message}),m==null||m(ce),E(oe)}else{const ce=se==null?void 0:se.firstName;if(pt(_t.CREATE_ACCOUNT_EVENT,{...se}),a||!u){if(l==null||l({userName:ce,userEmail:oe,status:!0}),a){(Be=M.target)==null||Be.reset(),C(""),b(!0),E(oe),O(!1);return}if(!u){O(!1),$({userName:ce,status:!0});return}}const K=await Ie({email:oe,password:ue,translations:r,handleSetInLineAlertProps:_,onErrorCallback:m});if(K!=null&&K.userName){if(t!=null&&t.length)for(const qe of t)try{await Et(qe)}catch(at){console.error(r.failedCreateCustomerAddress,qe,at)}l==null||l({userName:K==null?void 0:K.userName,userEmail:K==null?void 0:K.userEmail,status:!0}),q(i)?j(i()):$({userName:K==null?void 0:K.userName,status:!0})}else l==null||l({userName:ce,userEmail:oe,status:!0}),$({userName:ce,status:!0})}O(!1)},signInButton:P,handleSetSignUpPasswordValue:I,onKeepMeLoggedChange:me,handleHideEmailConfirmationForm:Q,handleConfirmPasswordChange:k,onBlurPassword:Z,onBlurConfirmPassword:ne}},ze=({requireRetypePassword:e=!1,addressesData:t,formSize:r="default",inputsDefaultValueSet:a,fieldsConfigForApiVersion1:s,apiVersion2:n=!0,isAutoSignInEnabled:u=!0,hideCloseBtnOnEmailConfirmation:i=!1,routeRedirectOnEmailConfirmationClose:c,routeRedirectOnSignIn:m,routeSignIn:l,onErrorCallback:A,onSuccessCallback:_,setActiveComponent:w,slots:h})=>{const f=be({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch",shoppingAssistanceCheckboxTitle:"Auth.SignUpForm.shoppingAssistanceCheckboxTitle",shoppingAssistanceCheckboxTooltip:"Auth.SignUpForm.shoppingAssistanceCheckboxTooltip"}),{passwordConfigs:d,isEmailConfirmationRequired:T,remoteShoppingAssistanceConfigs:y}=Ke(),{fieldsListConfigs:g}=Ct({fieldsConfigForApiVersion1:s,apiVersion2:n,inputsDefaultValueSet:a}),{inLineAlertProps:N,handleSetInLineAlertProps:E}=ye(),{showPasswordErrorMessage:p,confirmPassword:b,confirmPasswordMessage:S,isKeepMeLogged:$,userEmail:v,showEmailConfirmationForm:C,isSuccessful:Y,isClickSubmit:B,signUpPasswordValue:L,isLoading:O,onSubmitSignUp:G,signInButton:ae,handleSetSignUpPasswordValue:Z,onKeepMeLoggedChange:ne,handleHideEmailConfirmationForm:k,handleConfirmPasswordChange:me,onBlurPassword:P,onBlurConfirmPassword:I}=Ot({requireRetypePassword:e,addressesData:t,translations:f,isEmailConfirmationRequired:T,apiVersion2:n,passwordConfigs:d,isAutoSignInEnabled:u,routeRedirectOnSignIn:m,routeSignIn:l,onErrorCallback:A,onSuccessCallback:_,setActiveComponent:w,handleSetInLineAlertProps:E,routeRedirectOnEmailConfirmationClose:c}),{isValidUniqueSymbols:Q,defaultLengthMessage:W}=Je({password:L,isClickSubmit:B,passwordConfigs:d}),ee=xe(()=>p?f.requiredFieldError:Q==="error"||(W==null?void 0:W.status)==="error"?" ":"",[W==null?void 0:W.status,Q,p,f.requiredFieldError]),_e=!T&&(t==null?void 0:t.length);if(!g.length&&n)return o("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:o(yt,{activeSkeleton:"signUpForm"})});if(Y.status&&(h!=null&&h.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:h==null?void 0:h.SuccessNotification,context:{isSuccessful:Y}});if(C)return o(Xe,{formSize:r,userEmail:v,inLineAlertProps:N,hideCloseBtnOnEmailConfirmation:i,handleSetInLineAlertProps:E,onPrimaryButtonClick:k});const M={userEmail:v,signUpPasswordValue:L,confirmPassword:b,showPasswordErrorMessage:p,confirmPasswordMessage:S,isLoading:O,isSuccessful:Y};return R("div",{className:re(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[o(D,{name:"Title","data-testid":"title",slot:h==null?void 0:h.Title,context:{...M},children:o(ge,{title:f.title,divider:!1,className:"auth-sign-up-form__title",level:1})}),N.text?o(fe,{className:"auth-sign-up-form__notification",type:N.type,variant:"secondary",heading:N.text,icon:N.icon}):null,R(Fe,{onSubmit:G,className:"auth-sign-up-form__form",loading:O,name:"signUp_form",fieldsConfig:g,slots:h,formSlot:{name:"Form",slot:h==null?void 0:h.Form,context:M,dataTestId:"form"},children:[R(Te,{validateLengthConfig:W,className:"auth-sign-up-form__form__field",autoComplete:"new-password",name:"password",minLength:d==null?void 0:d.minLength,errorMessage:ee,defaultValue:L,uniqueSymbolsStatus:Q,requiredCharacterClasses:d==null?void 0:d.requiredCharacterClasses,onValue:Z,placeholder:f.placeholder,floatingLabel:f.floatingLabel,onBlur:P,children:[e?o("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:o(Te,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"new-password",name:"confirmPasswordField",placeholder:f.confirmPasswordPlaceholder,floatingLabel:f.confirmPasswordFloatingLabel,errorMessage:S,defaultValue:b,onValue:me,onBlur:I})}):null,_e?o("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:o(Re,{children:o(Se,{name:"",placeholder:f.keepMeLoggedText,label:f.keepMeLoggedText,checked:$,onChange:ne})})}):null]}),y!=null&&y.shoppingAssistanceEnabled?o(D,{name:"RemoteShoppingAssistanceConsent","data-testid":"remoteShoppingAssistanceConsent",slot:h==null?void 0:h.RemoteShoppingAssistanceConsent,children:o(nr,{label:y.shoppingAssistanceCheckboxTitle||f.shoppingAssistanceCheckboxTitle,tooltip:y.shoppingAssistanceCheckboxTooltip||f.shoppingAssistanceCheckboxTooltip})},"remoteShoppingAssistanceConsent"):null,o(D,{name:"PrivacyPolicyConsent","data-testid":"privacyPolicyConsent",slot:h==null?void 0:h.PrivacyPolicyConsent},"privacyPolicyConsent"),R(D,{name:"Buttons",className:"auth-sign-up-form-buttons","data-testid":"buttons",slot:h==null?void 0:h.Buttons,context:{...M},children:[o(te,{className:"auth-sign-up-form-buttons--signin",type:"button",variant:"tertiary",style:{padding:0},buttonText:f.buttonSecondary,enableLoader:!1,onClick:ae}),o(te,{type:"submit",buttonText:f.buttonPrimary,variant:"primary",enableLoader:O})]})]}),o("div",{id:"createCustomerV2"})]})},pr=Object.freeze(Object.defineProperty({__proto__:null,SignUpForm:ze,default:ze},Symbol.toStringTag,{value:"Module"})),Bt=({emailConfirmationStatusMessage:e,translations:t,initialEmailValue:r,routeSignUp:a,routeForgotPassword:s,routeRedirectOnSignIn:n,onErrorCallback:u,setActiveComponent:i,onSuccessCallback:c,onSignUpLinkClick:m,handleSetInLineAlertProps:l,routeRedirectOnEmailConfirmationClose:A,apiErrorMessageOverride:_})=>{const[w,h]=x(""),[f,d]=x(!1),[T,y]=x(""),[g,N]=x(!1),[E,p]=x({userName:"",status:!1}),[b,S]=x(!1),[$,v]=x([]),C=F(async P=>{l(),d(!0),N(!1),v([]),await Ze(P)},[l]),Y=F(P=>{P.length?N(!1):N(!0),y(P)},[]);ie(()=>{e!=null&&e.text&&l({text:e.text,type:e.status?e.status:void 0})},[e,l]);const B=F(()=>{T.length||N(!0)},[T]),L=F((P,I)=>T.length?!1:(N(!0),I&&Me(P,T,""),!0),[T]),O=F((P,I)=>{I!=null&&I.userName&&(P.target.reset(),q(n)?j(n()):(c==null||c({userName:I==null?void 0:I.userName,status:!0}),p({userName:I==null?void 0:I.userName,status:!0})))},[c,n]),G=F((P,I)=>{var Q;if((Q=P==null?void 0:P.errorMessage)!=null&&Q.length){h(I);const W=P.errorMessage.includes("This account isn't confirmed. Verify and try again."),ee=W?t.resendEmailInformationText:P.displayErrorMessage;v(W?[{label:t.resendEmailButtonText,onClick:()=>{C(I)}}]:[]),l({text:ee,type:"error"}),y("")}},[C,l,t.resendEmailButtonText,t.resendEmailInformationText]),ae=F(async(P,I)=>{if(l(),L(P,I))return;S(!0);const Q=we(P.target);if(Object.values(Q).every(ee=>ee)){const{email:ee,password:_e}=Q,M=await Ie({email:ee,password:_e,handleSetInLineAlertProps:l,onErrorCallback:u,translations:t,apiErrorMessageOverride:_});G(M,ee),O(P,M),N(!1)}S(!1)},[t,u,L,G,O,l,_]),Z=F(()=>{if(q(i)){i("resetPasswordForm");return}q(s)&&j(s())},[s,i]),ne=F(()=>{if(q(m)&&m(),q(i)){i("signUpForm");return}q(a)&&j(a())},[m,a,i]),k=xe(()=>{const P=Ne(St);return r!=null&&r.length?P==null?void 0:P.map(I=>({...I,defaultValue:r})):P},[r]),me=F(()=>{l(),q(A)?j(A()):d(!1)},[l,A]);return{additionalActionsAlert:$,userEmail:w,defaultEnhancedEmailFields:k,passwordError:g,isSuccessful:E,isLoading:b,signInPasswordValue:T,showEmailConfirmationForm:f,setShowEmailConfirmationForm:d,setSignInPasswordValue:y,submitLogInUser:ae,forgotPasswordCallback:Z,onSignUpLinkClickCallback:ne,handledOnPrimaryButtonClick:me,handleSetPassword:Y,onBlurPassword:B}},qt=()=>{const e=new URL(window.location.href),t=e.searchParams.get("email"),r=e.searchParams.get("key");t&&r&&(e.searchParams.delete("email"),e.searchParams.delete("key"),window.history.replaceState({},document.title,e.toString()))},Dt=({enableEmailConfirmation:e})=>{const t=J({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[r,a]=x({text:"",status:""});return ie(()=>{if(e){const{search:s}=window.location;s.includes("email=")&&s.includes("key=")&&(async()=>{var c,m,l;const u=new URLSearchParams(s),i=await Tt({customerEmail:u.get("email"),customerConfirmationKey:u.get("key")});if(!i)return null;(c=i==null?void 0:i.errors)!=null&&c.length?a({text:i==null?void 0:i.errors[0].message,status:"error"}):(a({text:i.data.confirmEmail.customer.email?t.accountConfirmationEmailSuccessMessage.replace("{email}",(l=(m=i==null?void 0:i.data)==null?void 0:m.confirmEmail.customer)==null?void 0:l.email):t.accountConfirmMessage,status:"success"}),qt())})()}},[e,t]),{emailConfirmationStatusMessage:r}},He=({slots:e,labels:t,formSize:r="default",initialEmailValue:a="",renderSignUpLink:s=!1,enableEmailConfirmation:n=!1,hideCloseBtnOnEmailConfirmation:u=!1,routeRedirectOnEmailConfirmationClose:i,routeRedirectOnSignIn:c,routeForgotPassword:m,routeSignUp:l,onSuccessCallback:A,setActiveComponent:_,onErrorCallback:w,onSignUpLinkClick:h,apiErrorMessageOverride:f})=>{const d=be({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{emailConfirmationStatusMessage:T}=Dt({enableEmailConfirmation:n}),{inLineAlertProps:y,handleSetInLineAlertProps:g}=ye(),{userEmail:N,additionalActionsAlert:E,defaultEnhancedEmailFields:p,passwordError:b,isSuccessful:S,isLoading:$,signInPasswordValue:v,showEmailConfirmationForm:C,submitLogInUser:Y,forgotPasswordCallback:B,onSignUpLinkClickCallback:L,handledOnPrimaryButtonClick:O,handleSetPassword:G,onBlurPassword:ae}=Bt({translations:d,emailConfirmationStatusMessage:T,initialEmailValue:a,routeSignUp:l,routeForgotPassword:m,routeRedirectOnSignIn:c,setActiveComponent:_,onErrorCallback:w,onSuccessCallback:A,onSignUpLinkClick:h,handleSetInLineAlertProps:g,routeRedirectOnEmailConfirmationClose:i,apiErrorMessageOverride:f});if(S.status&&(e!=null&&e.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:e==null?void 0:e.SuccessNotification,context:{isSuccessful:S}});if(C)return o(Xe,{formSize:r,userEmail:N,inLineAlertProps:y,hideCloseBtnOnEmailConfirmation:u,handleSetInLineAlertProps:g,onPrimaryButtonClick:O});const Z={userEmail:N,signInPasswordValue:v,isLoading:$,passwordError:b,isSuccessful:S};return R("div",{className:re(["auth-sign-in-form",`auth-sign-in-form--${r}`]),"data-testid":"signInForm",children:[o(D,{name:"Title","data-testid":"title",slot:e==null?void 0:e.Title,context:{...Z},children:o(ge,{title:(t==null?void 0:t.formTitleText)??d.title,divider:!1,className:"auth-sign-in-form__title",level:1})}),y.text?o(fe,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:y.type,variant:"secondary",heading:y.text,icon:y.icon,additionalActions:E}):null,R(Fe,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:Y,loading:$,fieldsConfig:p,formSlot:{name:"Form",slot:e==null?void 0:e.Form,context:Z,dataTestId:"form"},children:[o(Te,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:b?d.requiredFieldError:void 0,defaultValue:v,onValue:G,onBlur:ae,placeholder:d.placeholder,floatingLabel:d.floatingLabel}),o("div",{className:"auth-sign-in-form__form__buttons__wrapper",children:R(D,{name:"Buttons",className:"auth-sign-in-form__form__buttons","data-testid":"buttons",slot:e==null?void 0:e.Buttons,context:{...Z},children:[R("div",{className:"auth-sign-in-form__form__buttons__combine",children:[o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:d.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:B,"data-testid":"switchToSignUp"}),s?R(Ae,{children:[o("span",{}),o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:d.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:L})]}):null]}),o(te,{type:"submit",buttonText:(t==null?void 0:t.primaryButtonText)??d.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:$})]})})]}),o("div",{id:"generateCustomerToken"})]})},_r=Object.freeze(Object.defineProperty({__proto__:null,SignInForm:He,default:He},Symbol.toStringTag,{value:"Module"})),kt=e=>e.reduce((t,r)=>({...t,[r.name]:r.value}),{}),Wt=e=>/^\d+$/.test(e),zt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Ht=e=>/^[a-zA-Z0-9]+$/.test(e),Vt=e=>/^[a-zA-Z]+$/.test(e),Ye=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),jt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Gt=(e,t,r)=>{const a=new Date(e).getTime()/1e3;return!(isNaN(a)||a<0||typeof t<"u"&&a<t||typeof r<"u"&&a>r)},Ee=e=>{if(!e||e.trim()==="")return"";const t=parseInt(e,10);if(!isNaN(t)){const s=new Date(t*1e3);return isNaN(s.getTime())?"":s.toISOString().split("T")[0]}const r=new Date(e);if(isNaN(r.getTime()))return"";const a=parseInt(e.split("-")[1],10);return a>12||a<1?"":r.toISOString().split("T")[0]},Zt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),Xt=(e,t,r)=>{const a=e.length;return a>=t&&a<=r},ve=(e,t,r,a)=>{var $,v;const{requiredFieldError:s,lengthTextError:n,numericError:u,alphaNumWithSpacesError:i,alphaNumericError:c,alphaError:m,emailError:l,dateError:A,urlError:_,dateRangeError:w,dateMaxError:h,dateMinError:f}=r,d=t==null?void 0:t.customUpperCode,T={[d]:""};if(a[d]&&delete a[d],t!=null&&t.required&&(!e||e==="false"))return{[d]:`${H.REQUIRED_FIELD_ERROR}${V}${s}`};if(!(t!=null&&t.required)&&!e||!(($=t==null?void 0:t.validateRules)!=null&&$.length))return T;const y=kt(t==null?void 0:t.validateRules),g=y.MIN_TEXT_LENGTH??1,N=y.MAX_TEXT_LENGTH??255,E=y.DATE_RANGE_MIN,p=y.DATE_RANGE_MAX;if(!Xt(e,+g,+N)&&!(E||p)){const C=n.replace("{min}",g).replace("{max}",N);return{[d]:`${H.LENGTH_TEXT_ERROR}${V}${C}`}}if(!Gt(e,+E,+p)&&(E||p)){if(E&&E){const C=w.replace("{min}",Ee(E)).replace("{max}",Ee(p));return{[d]:`${H.DATE_RANGE_ERROR}${V}${C}`}}if(typeof E>"u"&&typeof p<"u"){const C=h.replace("{max}",Ee(p));return{[d]:`${H.DATE_MAX_ERROR}${V}${C}`}}if(typeof p>"u"&&typeof E<"u"){const C=f.replace("{min}",Ee(E));return{[d]:`${H.DATE_MIN_ERROR}${V}${C}`}}}const S={numeric:{validate:Wt,error:`${H.NUMERIC_ERROR}${V}${u}`},"alphanum-with-spaces":{validate:zt,error:`${H.ALPHA_NUM_WITH_SPACES_ERROR}${V}${i}`},alphanumeric:{validate:Ht,error:`${H.ALPHA_NUMERIC_ERROR}${V}${c}`},alpha:{validate:Vt,error:`${H.ALPHA_ERROR}${V}${m}`},email:{validate:Ye,error:`${H.EMAIL_ERROR}${V}${l}`},date:{validate:jt,error:`${H.DATE_ERROR}${V}${A}`},url:{validate:Zt,error:`${H.URL_ERROR}${V}${_}`}}[y.INPUT_VALIDATION];return S&&!S.validate(e)&&!((v=a[d])!=null&&v.length)?{[d]:S.error}:T},Kt=({routeSignIn:e,onErrorCallback:t,onSuccessCallback:r,setActiveComponent:a,handleSetInLineAlertProps:s})=>{const n=J({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[u,i]=x(!1),c=F(async l=>{l.preventDefault();const A=we(l.target);if(!Ye(A==null?void 0:A.email))return;i(!0);const _=await Nt(A.email);if(i(!1),!_.success){t==null||t(_),s==null||s({type:"error",text:_.message});return}if(r){await r();return}s==null||s({type:"success",text:n.successPasswordResetEmailNotification.replace("{email}",A.email)})},[s,t,r,n.successPasswordResetEmailNotification]),m=F(()=>{if(q(a)){a("signInForm");return}q(e)&&j(e())},[a,e]);return{isLoading:u,submitResetPassword:c,redirectToSignInPage:m}},Ve=({formSize:e="default",routeSignIn:t,setActiveComponent:r,onErrorCallback:a,onSuccessCallback:s,slots:n,...u})=>{const i=J({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:c,handleSetInLineAlertProps:m}=ye(),{isLoading:l,submitResetPassword:A,redirectToSignInPage:_}=Kt({routeSignIn:t,setActiveComponent:r,onErrorCallback:a,onSuccessCallback:s,handleSetInLineAlertProps:m}),w={isLoading:l};return R("div",{...u,className:re(["auth-reset-password-form",`auth-reset-password-form--${e}`]),"data-testid":"resetPasswordForm",children:[o(D,{name:"Title","data-testid":"title",slot:n==null?void 0:n.Title,context:{...w},children:o(ge,{title:i.title,divider:!1,className:"auth-reset-password-form__title",level:1})}),c.text?o(fe,{className:"auth-reset-password-form__notification",type:c.type,variant:"secondary",heading:c.text,icon:c.icon}):null,o(Fe,{"aria-labelledby":i.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:A,loading:l,fieldsConfig:Ne(It),formSlot:{name:"Form",slot:n==null?void 0:n.Form,context:w,dataTestId:"form"},children:R(D,{name:"Buttons",className:"auth-reset-password-form__buttons","data-testid":"buttons",slot:n==null?void 0:n.Buttons,context:{...w},children:[o(te,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:o(Pt,{style:{transform:"rotate(90deg)"}}),buttonText:i.buttonSecondary,enableLoader:!1,onClick:_}),o(te,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:l})]})}),o("div",{id:"requestPasswordResetEmail"})]})},Er=Object.freeze(Object.defineProperty({__proto__:null,ResetPasswordForm:Ve,default:Ve},Symbol.toStringTag,{value:"Module"})),Jt=e=>e.reduce((t,{customUpperCode:r,required:a,defaultValue:s})=>(a&&r&&(t.initialData[r]=s||"",t.errorList[r]=""),t),{initialData:{},errorList:{}}),Yt=["auth-reset-password-form__buttons--signin","auth-sign-up-form-buttons--signin","auth-sign-in-form__button--forgot","auth-sign-in-form__button--signup"],Qt=({fieldsConfig:e,onSubmit:t})=>{const r=be({requiredFieldError:"Auth.FormText.requiredFieldError.default",lengthTextError:"Auth.FormText.lengthTextError.default",numericError:"Auth.FormText.numericError.default",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError.default",alphaNumericError:"Auth.FormText.alphaNumericError.default",alphaError:"Auth.FormText.alphaError.default",emailError:"Auth.FormText.emailError.default",dateError:"Auth.FormText.dateError.default",dateRangeError:"Auth.FormText.dateRangeError.default",dateMaxError:"Auth.FormText.dateMaxError.default",dateMinError:"Auth.FormText.dateMinError.default",urlError:"Auth.FormText.urlError.default"}),a=De(null),s=De(!1),[n,u]=x({}),[i,c]=x({}),m=F(()=>{let h=!0;const f={...i};let d=null;for(const[T,y]of Object.entries(n)){const g=e==null?void 0:e.find(E=>{var p;return(p=E==null?void 0:E.customUpperCode)==null?void 0:p.includes(T)}),N=ve(y.toString(),g,r,f);N[T]&&(Object.assign(f,N),h=!1),d||(d=Object.keys(f).find(E=>f[E])??null)}if(c(f),d&&a.current){const T=a.current.elements.namedItem(d);T==null||T.focus()}return h},[i,e,n,r]);ie(()=>{if(e!=null&&e.length){const{initialData:h,errorList:f}=Jt(e);u(d=>({...h,...d})),c(f)}},[JSON.stringify(e)]);const l=F(async h=>{const f=h.target,d=!Yt.some(T=>f.classList.contains(T));!s.current&&d&&(await nt(0),s.current=!0)},[]),A=F(h=>{const{name:f,value:d,type:T,checked:y}=h==null?void 0:h.target,g=T==="checkbox"?y:d;u(p=>({...p,[f]:g}));const N=e==null?void 0:e.find(p=>{var b;return(b=p==null?void 0:p.customUpperCode)==null?void 0:b.includes(f)}),E={...i};if(N){const p=ve(g.toString(),N,r,E);p&&Object.assign(E,p),c(E)}},[e,i,r]),_=F(h=>{const{name:f,value:d,type:T,checked:y}=h==null?void 0:h.target,g=T==="checkbox"?y:d,N=e==null?void 0:e.find(E=>E.customUpperCode===f);if(N){const E={...i},p=ve(g.toString(),N,r,E);p&&Object.assign(E,p),c(E)}},[i,e,r]),w=F(h=>{h.preventDefault();const f=m();t==null||t(h,f)},[m,t]);return{formData:n,errors:i,formRef:a,handleChange:A,handleBlur:_,handleSubmit:w,handleFocus:l}};var le=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(le||{});const Qe=e=>{const t={errorKey:"",defaultErrorMessage:""};if(!e)return t;const r=e.indexOf(V);return r===-1?t:{errorKey:e.substring(0,r).trim(),defaultErrorMessage:e.substring(r+V.length).trim()}},pe=de(({item:e,errorConfig:t,className:r,itemClassName:a,loading:s,children:n})=>{const{errorKey:u,defaultErrorMessage:i}=Qe(t),c=J(`Auth.FormText.${u}.${e.code}`)[e.code];let m="";return i.length&&(m=c||i),o(Re,{error:m,className:re([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${r}--${e.id}`,disabled:s||e.disabled,children:n},e.id)}),je=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,onFocus:n,className:u,itemClassName:i,loading:c})=>o(pe,{item:e,errorConfig:r,className:u,itemClassName:i,loading:c,children:o(ot,{type:"text",name:e.customUpperCode,value:t??e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,autocomplete:e.autocomplete,onBlur:a,onChange:s,onFocus:n})})),Ge=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>{var m;const c=(m=e.options.find(l=>l.isDefault))==null?void 0:m.value;return o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(st,{name:e.customUpperCode,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:a,handleSelect:s,defaultValue:c??t??e.defaultValue,value:c??t??e.defaultValue})})}),er=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(it,{type:"text",name:e.customUpperCode,value:t||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s,disabled:i||e.disabled})})),tr=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(Se,{name:e.customUpperCode,checked:t||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s})})),rr=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(ut,{name:e.customUpperCode,value:t??e.defaultValue,label:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s})})),ar=({slots:e,item:t,handleOnChange:r,handleOnBlur:a,handleOnFocus:s,errorConfig:n,errors:u})=>{const{errorKey:i,defaultErrorMessage:c}=Qe(n),m=J(`Auth.FormText.${i}.${t.code}`)[t.code];let l="";c.length&&(l=m||c);const A={inputName:t.customUpperCode,handleOnChange:r,handleOnBlur:a,handleOnFocus:s,errorMessage:l,errors:u,config:t};return o(D,{"data-testid":`signUpFormInput_${t.code}`,name:`SignUpFormInput_${t.code}`,slot:e==null?void 0:e[`SignUpFormInput_${t.code}`],context:A},t.id)},Fe=de(({slots:e,name:t,loading:r,children:a,className:s="defaultForm",fieldsConfig:n=[],onSubmit:u,formSlot:i,...c})=>{const{formData:m,errors:l,formRef:A,handleChange:_,handleBlur:w,handleSubmit:h,handleFocus:f}=Qt({onSubmit:u,fieldsConfig:n}),d=`${s}__field`,T=R(Ae,{children:[n.map(g=>{const N=l==null?void 0:l[g.customUpperCode],E=m==null?void 0:m[g.customUpperCode],p=!!(e!=null&&e[`SignUpFormInput_${g.code}`]),b=o(ar,{slots:e,item:g,handleOnChange:_,handleOnBlur:w,handleOnFocus:f,errorConfig:N,errors:l});switch(g.fieldType){case le.TEXT:return p?b:g.options.length?o(Ge,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,onFocus:f,itemClassName:d,className:s,loading:r}):o(je,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,onFocus:f,itemClassName:d,className:s,loading:r});case le.MULTILINE:return p?b:o(je,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,onFocus:f,itemClassName:d,className:s,loading:r});case le.SELECT:return p?b:o(Ge,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,itemClassName:d,className:s,loading:r});case le.DATE:return p?b:o(er,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,itemClassName:d,className:s,loading:r});case le.BOOLEAN:return p?b:o(tr,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,itemClassName:d,className:s,loading:r});case le.TEXTAREA:return p?b:o(rr,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:_,itemClassName:d,className:s,loading:r});default:return null}}),a]}),y={...(i==null?void 0:i.context)??{},__formContentKey:[n.map(g=>g.id||g.code).join(","),JSON.stringify(l),JSON.stringify(m)].join("|")};return o("form",{onSubmit:h,name:t,ref:A,onFocus:f,...c,children:i?o(D,{name:i.name,slot:i.slot,context:y,className:s,"data-testid":i.dataTestId,children:T}):T})}),te=({type:e,buttonText:t,variant:r,className:a="",enableLoader:s=!1,onClick:n,style:u,icon:i,...c})=>{const m=F(A=>{n==null||n(A)},[n]);return R(Pe,{icon:i,style:u,type:e,variant:r,className:re(["auth-button",a,s?"enableLoader":""]),onClick:m,...c,children:[o("span",{className:"auth-button__text",children:t}),s?o("div",{className:"auth-button__wrapper",children:o("span",{className:"auth-button__loader"})}):null]})},nr=({label:e="",tooltip:t="",name:r="allowRemoteShoppingAssistance",defaultChecked:a=!1,onChange:s,className:n=""})=>{const[u,i]=x(!1),[c,m]=x(a),l=`${r}-tooltip`,A=({currentTarget:_})=>{const w=_.checked;m(w),s==null||s(w)};return o("div",{className:re(["remote-shopping-assistance-consent",n]),children:R("div",{className:"remote-shopping-assistance-consent__wrapper",children:[o(Re,{children:o(Se,{name:r,value:"true",placeholder:e,label:e,checked:c,onChange:A})}),t?R("div",{className:"remote-shopping-assistance-consent__info-container",children:[o("button",{type:"button",className:"remote-shopping-assistance-consent__info-icon",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocusIn:()=>i(!0),onFocusOut:()=>i(!1),"aria-describedby":u?l:void 0,"aria-label":t,children:"?"}),u?R("span",{className:"remote-shopping-assistance-consent__tooltip",id:l,role:"tooltip",children:[t,o("span",{className:"remote-shopping-assistance-consent__tooltip-arrow"})]}):null]}):null]})})};export{Ve as R,yt as S,fr as U,He as a,ze as b,gr as c,_r as d,Er as e,pr as i};
|
|
3
|
+
import{jsxs as R,jsx as o,Fragment as Ae}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as xe,useState as x,useCallback as F,useEffect as ie,useRef as De}from"@dropins/tools/preact-hooks.js";import{classes as re,Slot as D}from"@dropins/tools/lib.js";import{useText as G}from"@dropins/tools/i18n.js";import"@dropins/tools/event-bus.js";import{initReCaptcha as nt}from"@dropins/tools/recaptcha.js";import{Skeleton as Le,SkeletonRow as U,InLineAlert as fe,Header as ge,InputPassword as Te,Button as Pe,Field as Re,Checkbox as Se,Input as ot,Picker as st,InputDate as it,TextArea as ut}from"@dropins/tools/components.js";import*as z from"@dropins/tools/preact-compat.js";import{memo as de}from"@dropins/tools/preact-compat.js";import{resendConfirmationEmail as Ze,getStoreConfig as ct,resetPassword as lt,getCustomerToken as Ie,revokeCustomerToken as dt,t as mt,getAttributesForm as ht,c as ft,createCustomer as gt,p as pt,E as _t,createCustomerAddress as Et,confirmEmail as Tt,requestPasswordResetEmail as Nt}from"../api.js";const At=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),xt=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),wt=()=>R(Le,{children:[o(U,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",o(U,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),yt=({activeSkeleton:e})=>{const t=xe(()=>({signInForm:o(xt,{}),signUpForm:o(At,{}),resetPasswordForm:o(wt,{})}),[]);return o(Ae,{children:t[e]})},bt=({userEmail:e,handleSetInLineAlertProps:t})=>{const r=G({emailConfirmationMessage:"Auth.Notification.emailConfirmationMessage",technicalErrorSendEmail:"Auth.Notification.technicalErrors.technicalErrorSendEmail"}),[a,s]=x(!1);return{handleEmailConfirmation:F(async()=>{var u,i;if(s(!0),e){const c=await Ze(e);if(c){const m=(u=c==null?void 0:c.errors)==null?void 0:u.length,l=(i=c==null?void 0:c.data)==null?void 0:i.resendConfirmationEmail;t(m?{type:"error",text:r.technicalErrorSendEmail}:{type:l?"success":"error",text:r.emailConfirmationMessage})}}s(!1)},[t,r,e]),disabledButton:a}},Xe=({formSize:e,userEmail:t,inLineAlertProps:r,hideCloseBtnOnEmailConfirmation:a,handleSetInLineAlertProps:s,onPrimaryButtonClick:n})=>{const u=G({title:"Auth.EmailConfirmationForm.title",subtitle:"Auth.EmailConfirmationForm.subtitle",mainText:"Auth.EmailConfirmationForm.mainText",buttonPrimary:"Auth.EmailConfirmationForm.buttonPrimary",buttonSecondary:"Auth.EmailConfirmationForm.buttonSecondary"}),{handleEmailConfirmation:i,disabledButton:c}=bt({userEmail:t,handleSetInLineAlertProps:s});return R("div",{className:re(["auth-email-confirmation-form",`auth-email-confirmation-form--${e}`]),children:[r.text?o(fe,{className:"auth-signInForm__notification",type:r.type,variant:"secondary",heading:r.text,icon:r.icon,"data-testid":"authInLineAlert"}):null,o(ge,{title:u.title,divider:!1,className:"auth-email-confirmation-form__title"}),t!=null&&t.length?o("span",{className:"auth-email-confirmation-form__subtitle",children:`${u.subtitle} ${t}`}):null,o("span",{className:"auth-email-confirmation-form__text",children:u.mainText}),R("div",{className:"auth-email-confirmation-form__buttons",children:[o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:u.buttonSecondary,enableLoader:!1,onClick:i,disabled:c}),a?null:o(te,{type:"submit",buttonText:u.buttonPrimary,variant:"primary",enableLoader:!1,disabled:c,onClick:n})]})]})},Ke=()=>{const[e,t]=x(!1),[r,a]=x(null),[s,n]=x(null),u=i=>{const{minLength:c,requiredCharacterClasses:m,createAccountConfirmation:l,shoppingAssistanceEnabled:A,shoppingAssistanceCheckboxTitle:p,shoppingAssistanceCheckboxTooltip:w}=i;a({minLength:c,requiredCharacterClasses:m}),t(l),n({shoppingAssistanceEnabled:A,shoppingAssistanceCheckboxTitle:p,shoppingAssistanceCheckboxTooltip:w})};return ie(()=>{const i=sessionStorage.getItem("storeConfig");let c=null;try{c=i?JSON.parse(i):null}catch{c=null}if(c){u(c);return}ct().then(m=>{m&&(sessionStorage.setItem("storeConfig",JSON.stringify(m)),u(m))})},[]),{passwordConfigs:r,isEmailConfirmationRequired:e,remoteShoppingAssistanceConfigs:s}},Ue=(e,t)=>{if(t<=1)return!0;const r=/[0-9]/.test(e)?1:0,a=/[a-z]/.test(e)?1:0,s=/[A-Z]/.test(e)?1:0,n=/[^a-zA-Z0-9\s]/.test(e)?1:0;return r+a+s+n>=t},Je=({passwordConfigs:e,isClickSubmit:t,password:r})=>{const a=G({messageLengthPassword:"Auth.PasswordValidationMessage.messageLengthPassword"}),[s,n]=x("pending");ie(()=>{if(!e)return;const i=Ue(r,e.requiredCharacterClasses);t&&r.length>0?n(i?"success":"error"):t&&r.length===0?n("pending"):n(i?"success":"pending")},[t,e,r]);const u=xe(()=>{var c;if(!e)return;const i={status:"pending",icon:"pending",message:(c=a.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return r.length&&r.length>=e.minLength?{...i,icon:"success",status:"success"}:r.length&&r.length<e.minLength?t?{...i,icon:"error",status:"error"}:{...i,icon:"pending",status:"pending"}:i},[e,a.messageLengthPassword,r==null?void 0:r.length,t]);return{isValidUniqueSymbols:s,defaultLengthMessage:u}},we=e=>{if(!e)return null;const t=new FormData(e);if(t&&typeof t.entries=="function"){const r=t.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},ke=(e,t)=>e.split("&").filter(a=>a.includes(t)).map(a=>a.split("=")[1])[0],q=e=>typeof e=="function",j=e=>{window.location.href=e},Ft=({isEmailConfirmationRequired:e,signInOnSuccess:t,passwordConfigs:r,routeRedirectOnSignIn:a,routeWrongUrlRedirect:s,onErrorCallback:n,onSuccessCallback:u,handleSetInLineAlertProps:i,routeRedirectOnPasswordUpdate:c,routeSignInPage:m})=>{const l=G({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[A,p]=x({userName:"",status:!1}),[w,h]=x(""),[f,d]=x(!1),[T,y]=x(""),[g,N]=x(""),[E,_]=x(!1),[b,S]=x(!1),[$,v]=x([]);ie(()=>{f&&!$.length&&(w.length?S(!1):S(!0))},[f,w,$]),ie(()=>{const{search:B}=window.location;!B.includes("token=")&&!B.includes("email=")&&q(s)&&j(s());const L=decodeURIComponent(B),O=ke(L,"token"),Z=ke(L,"email");y(Z),N(O)},[s]);const C=F(async B=>{B.preventDefault(),_(!0),v([]);const L=we(B.target),O=(L==null?void 0:L.password)&&T&&g;L!=null&&L.password||(S(!0),_(!1));const Z=(r==null?void 0:r.requiredCharacterClasses)??0,ae=(r==null?void 0:r.minLength)??0;if(!Ue(L==null?void 0:L.password,Z)||L.password.length<+ae){d(!0),_(!1);return}if(!O){i({type:"error",text:l.errorNotification}),_(!1);return}const{message:X,success:ne}=await lt(T,g,L.password);if(ne){if(e||!e&&!t){u==null||u(),q(c)&&j(c()),d(!0),_(!1),S(!1),h(""),v([{label:l.updatePasswordActionMessage,onClick:()=>{j(m==null?void 0:m())}}]),i({type:"success",text:l.updatePasswordMessage});return}const k=await Ie({email:T,password:L.password,handleSetInLineAlertProps:i,onErrorCallback:n,translations:l});k!=null&&k.userName&&(u==null||u(k==null?void 0:k.userName),q(a)?j(a()):p({userName:k==null?void 0:k.userName,status:!0}))}else i({type:"error",text:X}),n==null||n({message:X,success:ne});_(!1)},[T,g,r==null?void 0:r.requiredCharacterClasses,r==null?void 0:r.minLength,l,e,t,m,n,u,a,i,c]),Y=F(B=>{h(B)},[]);return{additionalActionsAlert:$,passwordError:b,isSuccessful:A,updatePasswordValue:w,isClickSubmit:f,isLoading:E,submitUpdatePassword:C,handleSetUpdatePasswordValue:Y,setIsClickSubmit:d}},vt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Pt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round"})),Mt=e=>z.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("g",{clipPath:"url(#clip0_841_1324)"},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),z.createElement("defs",null,z.createElement("clipPath",{id:"clip0_841_1324"},z.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)",strokeWidth:1})))),Lt=e=>z.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),z.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Rt={success:o(vt,{}),warning:o(Mt,{}),error:o(Lt,{})},ye=()=>{const[e,t]=x({}),r=F(a=>{if(!a||!a.type){t({});return}const s=Rt[a.type];t({...a,icon:s})},[]);return{inLineAlertProps:e,handleSetInLineAlertProps:r}};var H=(e=>(e.REQUIRED_FIELD_ERROR="requiredFieldError",e.NUMERIC_ERROR="numericError",e.ALPHA_NUM_WITH_SPACES_ERROR="alphaNumWithSpacesError",e.ALPHA_NUMERIC_ERROR="alphaNumericError",e.ALPHA_ERROR="alphaError",e.EMAIL_ERROR="emailError",e.DATE_ERROR="dateError",e.DATE_RANGE_ERROR="dateRangeError",e.DATE_MAX_ERROR="dateMaxError",e.DATE_MIN_ERROR="dateMinError",e.URL_ERROR="urlError",e.LENGTH_TEXT_ERROR="lengthTextError",e))(H||{});const V="/",be=e=>{const t=G(e),r=Object.entries(t).filter(([n,u])=>u===null&&Object.values(H).includes(n)).map(([n])=>n),a=r.reduce((n,u)=>(n[u]=`Auth.FormText.${u}`,n),{}),s=G(a);return{...t,...r.reduce((n,u)=>(n[u]=s[u],n),{})}},fr=({signInOnSuccess:e=!0,formSize:t="default",routeRedirectOnSignIn:r,routeWrongUrlRedirect:a,routeSignInPage:s,slots:n,onErrorCallback:u,onSuccessCallback:i,routeRedirectOnPasswordUpdate:c})=>{const m=be({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{passwordConfigs:l,isEmailConfirmationRequired:A}=Ke(),{inLineAlertProps:p,handleSetInLineAlertProps:w}=ye(),{additionalActionsAlert:h,passwordError:f,isSuccessful:d,updatePasswordValue:T,isClickSubmit:y,isLoading:g,submitUpdatePassword:N,handleSetUpdatePasswordValue:E}=Ft({isEmailConfirmationRequired:A,signInOnSuccess:e,passwordConfigs:l,routeRedirectOnSignIn:r,routeWrongUrlRedirect:a,onErrorCallback:u,onSuccessCallback:i,handleSetInLineAlertProps:w,routeRedirectOnPasswordUpdate:c,routeSignInPage:s}),{isValidUniqueSymbols:_,defaultLengthMessage:b}=Je({password:T,isClickSubmit:y,passwordConfigs:l});if(d.status&&(n!=null&&n.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:n==null?void 0:n.SuccessNotification,context:{isSuccessful:d}});const S={updatePasswordValue:T,isLoading:g,passwordError:f,isSuccessful:d};return R("div",{className:re(["auth-update-password-form",`auth-update-password-form--${t}`]),children:[o(D,{name:"Title","data-testid":"title",slot:n==null?void 0:n.Title,context:{...S},children:o(ge,{title:m.title,divider:!1,className:"auth-update-password-form__title",level:1})}),o(fe,{className:re(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(p!=null&&p.text)]]),variant:"secondary",heading:p==null?void 0:p.text,icon:p.icon,additionalActions:h}),R(Fe,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:N,loading:g,fieldsConfig:[],formSlot:{name:"Form",slot:n==null?void 0:n.Form,context:S,dataTestId:"form"},children:[o("div",{style:"display: none;",children:o("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),o(Te,{defaultValue:T,onValue:E,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:f||_==="error"||(b==null?void 0:b.status)==="error"?m.requiredFieldError:void 0,minLength:l==null?void 0:l.minLength,uniqueSymbolsStatus:_,validateLengthConfig:b,requiredCharacterClasses:l==null?void 0:l.requiredCharacterClasses,placeholder:m.placeholder,floatingLabel:m.floatingLabel}),o(D,{name:"Buttons",className:"auth-update-password-form__button","data-testid":"buttons",slot:n==null?void 0:n.Buttons,context:{...S},children:o(te,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:g})})]})]})},gr=({formSize:e="default",className:t="",slots:r,labels:a})=>{const s=G({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return R("div",{className:re(["auth-success-notification-form",`auth-success-notification-form--${e}`,t]),id:"welcome-message",role:"alert","aria-live":"assertive","aria-labelledby":(a==null?void 0:a.headingText)??s.headingText,"aria-describedby":(a==null?void 0:a.messageText)??s.messageText,"tab-index":"-1",children:[o("p",{id:"welcome-heading",className:"auth-success-notification-form__title","data-testid":"notification-title",children:(a==null?void 0:a.headingText)??s.headingText}),o("p",{id:"welcome-details",className:"auth-success-notification-form__content-text","data-testid":"notification-content",children:(a==null?void 0:a.messageText)??s.messageText}),r!=null&&r.SuccessNotificationActions?o(D,{"data-testid":"successNotificationActions",name:"SuccessNotificationActions",slot:r==null?void 0:r.SuccessNotificationActions,context:{}}):R(Ae,{children:[o(Pe,{"data-testid":"primaryButton",type:"button",className:"auth-success-notification-form__button auth-success-notification-form__button--top",onClick:()=>j("/"),children:s.primaryButtonText}),o(Pe,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await dt(),j("/")},children:s.secondaryButtonText})]})]})},St=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-sign-in-form__form__email",frontend_input:"TEXT",is_required:!0,multiline_count:1,sort_order:1,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"}],It=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-reset-password-form__form__item",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"}],Ut=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",multiline_count:1,sort_order:1,options:[],validateRules:[{name:"INPUT_VALIDATION",value:"email"}],autocomplete:"email"},{customUpperCode:"firstname",code:"firstname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"First name",multiline_count:1,sort_order:2,options:[],autocomplete:"given-name"},{customUpperCode:"lastname",code:"lastname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!1,is_unique:!1,label:"Last name",multiline_count:1,sort_order:3,options:[],autocomplete:"family-name"}],Ne=e=>e!=null&&e.length?mt({data:{attributesForm:{items:e}}}):[],We=(e,t)=>t!=null&&t.length?e.map(r=>{var s;const a=(s=t.find(({code:n})=>n===r.code))==null?void 0:s.defaultValue;return a?{...r,defaultValue:a}:r}):e,Ct=({inputsDefaultValueSet:e,fieldsConfigForApiVersion1:t,apiVersion2:r})=>{const[a,s]=x([]);return ie(()=>{(async()=>{if(r){const u=await ht("customer_account_create");if(u!=null&&u.length)if(e!=null&&e.length){const i=We(u,e);s(i)}else s(u)}else{const u=Ne(Ut),i=Ne(t),c=We(u,e);s(t&&t.length?i:c)}})()},[r,t,e]),{fieldsListConfigs:a.map(n=>({...n,...n.code==="email"?{autocomplete:"email"}:{}}))}},$t=(e,t)=>{const r=["dob","email","firstname","gender","lastname","middlename","password","prefix","suffix","taxvat","allow_remote_shopping_assistance"],a=ft(e,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!t)return{...a,...a!=null&&a.gender?{gender:Number(a==null?void 0:a.gender)}:{}};const s={},n=[];return Object.keys(a).forEach(u=>{r.includes(u)?u.includes("gender")?s[u]=Number(a[u]):u==="allow_remote_shopping_assistance"?s[u]=a[u]==="true":s[u]=a[u]:n.push({attribute_code:u,value:a[u]})}),n.length>0&&(s.custom_attributes=n),s},Me=(e,t,r)=>{const a=e.target.querySelector('input[name="password"]'),s=e.target.querySelector('input[name="confirmPasswordField"]');a&&!t.length?a.focus():s&&!r.length&&s.focus()},Ot=({requireRetypePassword:e,addressesData:t,translations:r,isEmailConfirmationRequired:a,apiVersion2:s=!0,passwordConfigs:n,isAutoSignInEnabled:u,routeRedirectOnSignIn:i,routeSignIn:c,onErrorCallback:m,onSuccessCallback:l,setActiveComponent:A,handleSetInLineAlertProps:p,routeRedirectOnEmailConfirmationClose:w})=>{const[h,f]=x(!1),[d,T]=x(""),[y,g]=x(""),[N,E]=x(""),[_,b]=x(!1),[S,$]=x({userName:"",status:!1}),[v,C]=x(""),[Y,B]=x(!1),[L,O]=x(!1),[Z,ae]=x(!0),X=F(M=>{const K=M.target.value;f(!K.length),K.length&&d.length&&K!==d&&g(r.passwordMismatch)},[d,r.passwordMismatch]),ne=F(M=>{const K=M.target.value;g(K.length?"":r.requiredFieldError),K.length&&v.length&&K!==v&&g(r.passwordMismatch)},[v,r.passwordMismatch,r.requiredFieldError]),k=F(M=>{T(M),g(M?v===M?"":r.passwordMismatch:r.requiredFieldError)},[r,v]),me=F(({target:M})=>{ae(M.checked)},[]),P=F(()=>{if(q(A)){A("signInForm");return}q(c)&&j(c())},[A,c]),I=F(M=>{C(M),f(!M.length),M===d&&g("")},[d]),Q=F(()=>{p(),C(""),q(w)?j(w()):(b(!1),A==null||A("signInForm"))},[p,w,A]),W=()=>{B(!0),O(!1)},ee=(M,K)=>{const Ce=v.length&&d.length,he=v!==d,oe=()=>{f(!v.length),d||g(r.requiredFieldError),Ce&&he&&g(r.passwordMismatch)},ue=()=>{g(d.length?r.passwordMismatch:r.requiredFieldError),Me(M,v,d)};return K?e&&(y.length||he)?(W(),ue(),!0):(Me(M,v,""),oe(),!1):(W(),oe(),!0)};return{showPasswordErrorMessage:h,confirmPassword:d,confirmPasswordMessage:y,isKeepMeLogged:Z,userEmail:N,showEmailConfirmationForm:_,isSuccessful:S,isClickSubmit:Y,signUpPasswordValue:v,isLoading:L,onSubmitSignUp:async(M,K)=>{var $e,Oe,Be;if(p(),g(""),O(!0),ee(M,K))return;const{confirmPasswordField:Ce,...he}=we(M.target),{email:oe,password:ue}=he,et=(n==null?void 0:n.requiredCharacterClasses)||0,tt=(n==null?void 0:n.minLength)||1;if(!Ue(ue,et)||tt>(ue==null?void 0:ue.length)){W();return}const rt=$t({...he},s),se=await gt(rt,s);if(($e=se==null?void 0:se.errors)!=null&&$e.length){const{errors:ce}=se;p==null||p({type:"error",text:(Oe=ce[0])==null?void 0:Oe.message}),m==null||m(ce),E(oe)}else{const ce=se==null?void 0:se.firstName;if(pt(_t.CREATE_ACCOUNT_EVENT,{...se}),a||!u){if(l==null||l({userName:ce,userEmail:oe,status:!0}),a){(Be=M.target)==null||Be.reset(),C(""),b(!0),E(oe),O(!1);return}if(!u){O(!1),$({userName:ce,status:!0});return}}const J=await Ie({email:oe,password:ue,translations:r,handleSetInLineAlertProps:p,onErrorCallback:m});if(J!=null&&J.userName){if(t!=null&&t.length)for(const qe of t)try{await Et(qe)}catch(at){console.error(r.failedCreateCustomerAddress,qe,at)}l==null||l({userName:J==null?void 0:J.userName,userEmail:J==null?void 0:J.userEmail,status:!0}),q(i)?j(i()):$({userName:J==null?void 0:J.userName,status:!0})}else l==null||l({userName:ce,userEmail:oe,status:!0}),$({userName:ce,status:!0})}O(!1)},signInButton:P,handleSetSignUpPasswordValue:I,onKeepMeLoggedChange:me,handleHideEmailConfirmationForm:Q,handleConfirmPasswordChange:k,onBlurPassword:X,onBlurConfirmPassword:ne}},ze=({requireRetypePassword:e=!1,addressesData:t,formSize:r="default",inputsDefaultValueSet:a,fieldsConfigForApiVersion1:s,apiVersion2:n=!0,isAutoSignInEnabled:u=!0,hideCloseBtnOnEmailConfirmation:i=!1,routeRedirectOnEmailConfirmationClose:c,routeRedirectOnSignIn:m,routeSignIn:l,onErrorCallback:A,onSuccessCallback:p,setActiveComponent:w,slots:h})=>{const f=be({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch",shoppingAssistanceCheckboxTitle:"Auth.SignUpForm.shoppingAssistanceCheckboxTitle",shoppingAssistanceCheckboxTooltip:"Auth.SignUpForm.shoppingAssistanceCheckboxTooltip"}),{passwordConfigs:d,isEmailConfirmationRequired:T,remoteShoppingAssistanceConfigs:y}=Ke(),{fieldsListConfigs:g}=Ct({fieldsConfigForApiVersion1:s,apiVersion2:n,inputsDefaultValueSet:a}),{inLineAlertProps:N,handleSetInLineAlertProps:E}=ye(),{showPasswordErrorMessage:_,confirmPassword:b,confirmPasswordMessage:S,isKeepMeLogged:$,userEmail:v,showEmailConfirmationForm:C,isSuccessful:Y,isClickSubmit:B,signUpPasswordValue:L,isLoading:O,onSubmitSignUp:Z,signInButton:ae,handleSetSignUpPasswordValue:X,onKeepMeLoggedChange:ne,handleHideEmailConfirmationForm:k,handleConfirmPasswordChange:me,onBlurPassword:P,onBlurConfirmPassword:I}=Ot({requireRetypePassword:e,addressesData:t,translations:f,isEmailConfirmationRequired:T,apiVersion2:n,passwordConfigs:d,isAutoSignInEnabled:u,routeRedirectOnSignIn:m,routeSignIn:l,onErrorCallback:A,onSuccessCallback:p,setActiveComponent:w,handleSetInLineAlertProps:E,routeRedirectOnEmailConfirmationClose:c}),{isValidUniqueSymbols:Q,defaultLengthMessage:W}=Je({password:L,isClickSubmit:B,passwordConfigs:d}),ee=xe(()=>_?f.requiredFieldError:Q==="error"||(W==null?void 0:W.status)==="error"?" ":"",[W==null?void 0:W.status,Q,_,f.requiredFieldError]),_e=!T&&(t==null?void 0:t.length);if(!g.length&&n)return o("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:o(yt,{activeSkeleton:"signUpForm"})});if(Y.status&&(h!=null&&h.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:h==null?void 0:h.SuccessNotification,context:{isSuccessful:Y}});if(C)return o(Xe,{formSize:r,userEmail:v,inLineAlertProps:N,hideCloseBtnOnEmailConfirmation:i,handleSetInLineAlertProps:E,onPrimaryButtonClick:k});const M={userEmail:v,signUpPasswordValue:L,confirmPassword:b,showPasswordErrorMessage:_,confirmPasswordMessage:S,isLoading:O,isSuccessful:Y};return R("div",{className:re(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[o(D,{name:"Title","data-testid":"title",slot:h==null?void 0:h.Title,context:{...M},children:o(ge,{title:f.title,divider:!1,className:"auth-sign-up-form__title",level:1})}),N.text?o(fe,{className:"auth-sign-up-form__notification",type:N.type,variant:"secondary",heading:N.text,icon:N.icon}):null,R(Fe,{onSubmit:Z,className:"auth-sign-up-form__form",loading:O,name:"signUp_form",fieldsConfig:g,slots:h,formSlot:{name:"Form",slot:h==null?void 0:h.Form,context:M,dataTestId:"form"},children:[R(Te,{validateLengthConfig:W,className:"auth-sign-up-form__form__field",autoComplete:"new-password",name:"password",minLength:d==null?void 0:d.minLength,errorMessage:ee,defaultValue:L,uniqueSymbolsStatus:Q,requiredCharacterClasses:d==null?void 0:d.requiredCharacterClasses,onValue:X,placeholder:f.placeholder,floatingLabel:f.floatingLabel,onBlur:P,children:[e?o("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:o(Te,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"new-password",name:"confirmPasswordField",placeholder:f.confirmPasswordPlaceholder,floatingLabel:f.confirmPasswordFloatingLabel,errorMessage:S,defaultValue:b,onValue:me,onBlur:I})}):null,_e?o("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:o(Re,{children:o(Se,{name:"",placeholder:f.keepMeLoggedText,label:f.keepMeLoggedText,checked:$,onChange:ne})})}):null]}),y!=null&&y.shoppingAssistanceEnabled?o(D,{name:"RemoteShoppingAssistanceConsent","data-testid":"remoteShoppingAssistanceConsent",slot:h==null?void 0:h.RemoteShoppingAssistanceConsent,children:o(nr,{label:y.shoppingAssistanceCheckboxTitle||f.shoppingAssistanceCheckboxTitle,tooltip:y.shoppingAssistanceCheckboxTooltip||f.shoppingAssistanceCheckboxTooltip})},"remoteShoppingAssistanceConsent"):null,o(D,{name:"PrivacyPolicyConsent","data-testid":"privacyPolicyConsent",slot:h==null?void 0:h.PrivacyPolicyConsent},"privacyPolicyConsent"),R(D,{name:"Buttons",className:"auth-sign-up-form-buttons","data-testid":"buttons",slot:h==null?void 0:h.Buttons,context:{...M},children:[o(te,{className:"auth-sign-up-form-buttons--signin",type:"button",variant:"tertiary",style:{padding:0},buttonText:f.buttonSecondary,enableLoader:!1,onClick:ae}),o(te,{type:"submit",buttonText:f.buttonPrimary,variant:"primary",enableLoader:O})]})]}),o("div",{id:"createCustomerV2"})]})},pr=Object.freeze(Object.defineProperty({__proto__:null,SignUpForm:ze,default:ze},Symbol.toStringTag,{value:"Module"})),Bt=({emailConfirmationStatusMessage:e,translations:t,initialEmailValue:r,routeSignUp:a,routeForgotPassword:s,routeRedirectOnSignIn:n,onErrorCallback:u,setActiveComponent:i,onSuccessCallback:c,onSignUpLinkClick:m,handleSetInLineAlertProps:l,routeRedirectOnEmailConfirmationClose:A,apiErrorMessageOverride:p})=>{const[w,h]=x(""),[f,d]=x(!1),[T,y]=x(""),[g,N]=x(!1),[E,_]=x({userName:"",status:!1}),[b,S]=x(!1),[$,v]=x([]),C=F(async P=>{l(),d(!0),N(!1),v([]),await Ze(P)},[l]),Y=F(P=>{P.length?N(!1):N(!0),y(P)},[]);ie(()=>{e!=null&&e.text&&l({text:e.text,type:e.status?e.status:void 0})},[e,l]);const B=F(()=>{T.length||N(!0)},[T]),L=F((P,I)=>T.length?!1:(N(!0),I&&Me(P,T,""),!0),[T]),O=F((P,I)=>{I!=null&&I.userName&&(P.target.reset(),q(n)?j(n()):(c==null||c({userName:I==null?void 0:I.userName,status:!0}),_({userName:I==null?void 0:I.userName,status:!0})))},[c,n]),Z=F((P,I)=>{var Q;if((Q=P==null?void 0:P.errorMessage)!=null&&Q.length){h(I);const W=P.errorMessage.includes("This account isn't confirmed. Verify and try again."),ee=W?t.resendEmailInformationText:P.displayErrorMessage;v(W?[{label:t.resendEmailButtonText,onClick:()=>{C(I)}}]:[]),l({text:ee,type:"error"}),y("")}},[C,l,t.resendEmailButtonText,t.resendEmailInformationText]),ae=F(async(P,I)=>{if(l(),L(P,I))return;S(!0);const Q=we(P.target);if(Object.values(Q).every(ee=>ee)){const{email:ee,password:_e}=Q,M=await Ie({email:ee,password:_e,handleSetInLineAlertProps:l,onErrorCallback:u,translations:t,apiErrorMessageOverride:p});Z(M,ee),O(P,M),N(!1)}S(!1)},[t,u,L,Z,O,l,p]),X=F(()=>{if(q(i)){i("resetPasswordForm");return}q(s)&&j(s())},[s,i]),ne=F(()=>{if(q(m)&&m(),q(i)){i("signUpForm");return}q(a)&&j(a())},[m,a,i]),k=xe(()=>{const P=Ne(St);return r!=null&&r.length?P==null?void 0:P.map(I=>({...I,defaultValue:r})):P},[r]),me=F(()=>{l(),q(A)?j(A()):d(!1)},[l,A]);return{additionalActionsAlert:$,userEmail:w,defaultEnhancedEmailFields:k,passwordError:g,isSuccessful:E,isLoading:b,signInPasswordValue:T,showEmailConfirmationForm:f,setShowEmailConfirmationForm:d,setSignInPasswordValue:y,submitLogInUser:ae,forgotPasswordCallback:X,onSignUpLinkClickCallback:ne,handledOnPrimaryButtonClick:me,handleSetPassword:Y,onBlurPassword:B}},qt=()=>{const e=new URL(window.location.href),t=e.searchParams.get("email"),r=e.searchParams.get("key");t&&r&&(e.searchParams.delete("email"),e.searchParams.delete("key"),window.history.replaceState({},document.title,e.toString()))},Dt=({enableEmailConfirmation:e})=>{const t=G({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[r,a]=x({text:"",status:""});return ie(()=>{if(e){const{search:s}=window.location;s.includes("email=")&&s.includes("key=")&&(async()=>{var c,m,l;const u=new URLSearchParams(s),i=await Tt({customerEmail:u.get("email"),customerConfirmationKey:u.get("key")});if(!i)return null;(c=i==null?void 0:i.errors)!=null&&c.length?a({text:i==null?void 0:i.errors[0].message,status:"error"}):(a({text:i.data.confirmEmail.customer.email?t.accountConfirmationEmailSuccessMessage.replace("{email}",(l=(m=i==null?void 0:i.data)==null?void 0:m.confirmEmail.customer)==null?void 0:l.email):t.accountConfirmMessage,status:"success"}),qt())})()}},[e,t]),{emailConfirmationStatusMessage:r}},He=({slots:e,labels:t,formSize:r="default",initialEmailValue:a="",renderSignUpLink:s=!1,enableEmailConfirmation:n=!1,hideCloseBtnOnEmailConfirmation:u=!1,routeRedirectOnEmailConfirmationClose:i,routeRedirectOnSignIn:c,routeForgotPassword:m,routeSignUp:l,onSuccessCallback:A,setActiveComponent:p,onErrorCallback:w,onSignUpLinkClick:h,apiErrorMessageOverride:f})=>{const d=be({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{emailConfirmationStatusMessage:T}=Dt({enableEmailConfirmation:n}),{inLineAlertProps:y,handleSetInLineAlertProps:g}=ye(),{userEmail:N,additionalActionsAlert:E,defaultEnhancedEmailFields:_,passwordError:b,isSuccessful:S,isLoading:$,signInPasswordValue:v,showEmailConfirmationForm:C,submitLogInUser:Y,forgotPasswordCallback:B,onSignUpLinkClickCallback:L,handledOnPrimaryButtonClick:O,handleSetPassword:Z,onBlurPassword:ae}=Bt({translations:d,emailConfirmationStatusMessage:T,initialEmailValue:a,routeSignUp:l,routeForgotPassword:m,routeRedirectOnSignIn:c,setActiveComponent:p,onErrorCallback:w,onSuccessCallback:A,onSignUpLinkClick:h,handleSetInLineAlertProps:g,routeRedirectOnEmailConfirmationClose:i,apiErrorMessageOverride:f});if(S.status&&(e!=null&&e.SuccessNotification))return o(D,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:e==null?void 0:e.SuccessNotification,context:{isSuccessful:S}});if(C)return o(Xe,{formSize:r,userEmail:N,inLineAlertProps:y,hideCloseBtnOnEmailConfirmation:u,handleSetInLineAlertProps:g,onPrimaryButtonClick:O});const X={userEmail:N,signInPasswordValue:v,isLoading:$,passwordError:b,isSuccessful:S};return R("div",{className:re(["auth-sign-in-form",`auth-sign-in-form--${r}`]),"data-testid":"signInForm",children:[o(D,{name:"Title","data-testid":"title",slot:e==null?void 0:e.Title,context:{...X},children:o(ge,{title:(t==null?void 0:t.formTitleText)??d.title,divider:!1,className:"auth-sign-in-form__title",level:1})}),y.text?o(fe,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:y.type,variant:"secondary",heading:y.text,icon:y.icon,additionalActions:E}):null,R(Fe,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:Y,loading:$,fieldsConfig:_,formSlot:{name:"Form",slot:e==null?void 0:e.Form,context:X,dataTestId:"form"},children:[o(Te,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:b?d.requiredFieldError:void 0,defaultValue:v,onValue:Z,onBlur:ae,placeholder:d.placeholder,floatingLabel:d.floatingLabel}),o("div",{className:"auth-sign-in-form__form__buttons__wrapper",children:R(D,{name:"Buttons",className:"auth-sign-in-form__form__buttons","data-testid":"buttons",slot:e==null?void 0:e.Buttons,context:{...X},children:[R("div",{className:"auth-sign-in-form__form__buttons__combine",children:[o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:d.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:B,"data-testid":"switchToSignUp"}),s?R(Ae,{children:[o("span",{}),o(te,{type:"button",variant:"tertiary",style:{padding:0},buttonText:d.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:L})]}):null]}),o(te,{type:"submit",buttonText:(t==null?void 0:t.primaryButtonText)??d.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:$})]})})]}),o("div",{id:"generateCustomerToken"})]})},_r=Object.freeze(Object.defineProperty({__proto__:null,SignInForm:He,default:He},Symbol.toStringTag,{value:"Module"})),kt=e=>e.reduce((t,r)=>({...t,[r.name]:r.value}),{}),Wt=e=>/^\d+$/.test(e),zt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Ht=e=>/^[a-zA-Z0-9]+$/.test(e),Vt=e=>/^[a-zA-Z]+$/.test(e),Ye=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),jt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),Gt=(e,t,r)=>{const a=new Date(e).getTime()/1e3;return!(isNaN(a)||a<0||typeof t<"u"&&a<t||typeof r<"u"&&a>r)},Ee=e=>{if(!e||e.trim()==="")return"";const t=parseInt(e,10);if(!isNaN(t)){const s=new Date(t*1e3);return isNaN(s.getTime())?"":s.toISOString().split("T")[0]}const r=new Date(e);if(isNaN(r.getTime()))return"";const a=parseInt(e.split("-")[1],10);return a>12||a<1?"":r.toISOString().split("T")[0]},Zt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),Xt=(e,t,r)=>{const a=e.length;return a>=t&&a<=r},ve=(e,t,r,a)=>{var $,v;const{requiredFieldError:s,lengthTextError:n,numericError:u,alphaNumWithSpacesError:i,alphaNumericError:c,alphaError:m,emailError:l,dateError:A,urlError:p,dateRangeError:w,dateMaxError:h,dateMinError:f}=r,d=t==null?void 0:t.customUpperCode,T={[d]:""};if(a[d]&&delete a[d],t!=null&&t.required&&(!e||e==="false"))return{[d]:`${H.REQUIRED_FIELD_ERROR}${V}${s}`};if(!(t!=null&&t.required)&&!e||!(($=t==null?void 0:t.validateRules)!=null&&$.length))return T;const y=kt(t==null?void 0:t.validateRules),g=y.MIN_TEXT_LENGTH??1,N=y.MAX_TEXT_LENGTH??255,E=y.DATE_RANGE_MIN,_=y.DATE_RANGE_MAX;if(!Xt(e,+g,+N)&&!(E||_)){const C=n.replace("{min}",g).replace("{max}",N);return{[d]:`${H.LENGTH_TEXT_ERROR}${V}${C}`}}if(!Gt(e,+E,+_)&&(E||_)){if(E&&E){const C=w.replace("{min}",Ee(E)).replace("{max}",Ee(_));return{[d]:`${H.DATE_RANGE_ERROR}${V}${C}`}}if(typeof E>"u"&&typeof _<"u"){const C=h.replace("{max}",Ee(_));return{[d]:`${H.DATE_MAX_ERROR}${V}${C}`}}if(typeof _>"u"&&typeof E<"u"){const C=f.replace("{min}",Ee(E));return{[d]:`${H.DATE_MIN_ERROR}${V}${C}`}}}const S={numeric:{validate:Wt,error:`${H.NUMERIC_ERROR}${V}${u}`},"alphanum-with-spaces":{validate:zt,error:`${H.ALPHA_NUM_WITH_SPACES_ERROR}${V}${i}`},alphanumeric:{validate:Ht,error:`${H.ALPHA_NUMERIC_ERROR}${V}${c}`},alpha:{validate:Vt,error:`${H.ALPHA_ERROR}${V}${m}`},email:{validate:Ye,error:`${H.EMAIL_ERROR}${V}${l}`},date:{validate:jt,error:`${H.DATE_ERROR}${V}${A}`},url:{validate:Zt,error:`${H.URL_ERROR}${V}${p}`}}[y.INPUT_VALIDATION];return S&&!S.validate(e)&&!((v=a[d])!=null&&v.length)?{[d]:S.error}:T},Kt=({routeSignIn:e,onErrorCallback:t,onSuccessCallback:r,setActiveComponent:a,handleSetInLineAlertProps:s})=>{const n=G({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[u,i]=x(!1),c=F(async l=>{l.preventDefault();const A=we(l.target);if(!Ye(A==null?void 0:A.email))return;i(!0);const p=await Nt(A.email);if(i(!1),!p.success){t==null||t(p),s==null||s({type:"error",text:p.message});return}if(r){await r();return}s==null||s({type:"success",text:n.successPasswordResetEmailNotification.replace("{email}",A.email)})},[s,t,r,n.successPasswordResetEmailNotification]),m=F(()=>{if(q(a)){a("signInForm");return}q(e)&&j(e())},[a,e]);return{isLoading:u,submitResetPassword:c,redirectToSignInPage:m}},Ve=({formSize:e="default",routeSignIn:t,setActiveComponent:r,onErrorCallback:a,onSuccessCallback:s,slots:n,...u})=>{const i=G({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:c,handleSetInLineAlertProps:m}=ye(),{isLoading:l,submitResetPassword:A,redirectToSignInPage:p}=Kt({routeSignIn:t,setActiveComponent:r,onErrorCallback:a,onSuccessCallback:s,handleSetInLineAlertProps:m}),w={isLoading:l};return R("div",{...u,className:re(["auth-reset-password-form",`auth-reset-password-form--${e}`]),"data-testid":"resetPasswordForm",children:[o(D,{name:"Title","data-testid":"title",slot:n==null?void 0:n.Title,context:{...w},children:o(ge,{title:i.title,divider:!1,className:"auth-reset-password-form__title",level:1})}),c.text?o(fe,{className:"auth-reset-password-form__notification",type:c.type,variant:"secondary",heading:c.text,icon:c.icon}):null,o(Fe,{"aria-labelledby":i.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:A,loading:l,fieldsConfig:Ne(It),formSlot:{name:"Form",slot:n==null?void 0:n.Form,context:w,dataTestId:"form"},children:R(D,{name:"Buttons",className:"auth-reset-password-form__buttons","data-testid":"buttons",slot:n==null?void 0:n.Buttons,context:{...w},children:[o(te,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:o(Pt,{style:{transform:"rotate(90deg)"}}),buttonText:i.buttonSecondary,enableLoader:!1,onClick:p}),o(te,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:l})]})}),o("div",{id:"requestPasswordResetEmail"})]})},Er=Object.freeze(Object.defineProperty({__proto__:null,ResetPasswordForm:Ve,default:Ve},Symbol.toStringTag,{value:"Module"})),Jt=e=>e.reduce((t,{customUpperCode:r,required:a,defaultValue:s})=>(a&&r&&(t.initialData[r]=s||"",t.errorList[r]=""),t),{initialData:{},errorList:{}}),Yt=["auth-reset-password-form__buttons--signin","auth-sign-up-form-buttons--signin","auth-sign-in-form__button--forgot","auth-sign-in-form__button--signup"],Qt=({fieldsConfig:e,onSubmit:t})=>{const r=be({requiredFieldError:"Auth.FormText.requiredFieldError.default",lengthTextError:"Auth.FormText.lengthTextError.default",numericError:"Auth.FormText.numericError.default",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError.default",alphaNumericError:"Auth.FormText.alphaNumericError.default",alphaError:"Auth.FormText.alphaError.default",emailError:"Auth.FormText.emailError.default",dateError:"Auth.FormText.dateError.default",dateRangeError:"Auth.FormText.dateRangeError.default",dateMaxError:"Auth.FormText.dateMaxError.default",dateMinError:"Auth.FormText.dateMinError.default",urlError:"Auth.FormText.urlError.default"}),a=De(null),s=De(!1),[n,u]=x({}),[i,c]=x({}),m=F(()=>{let h=!0;const f={...i};let d=null;for(const[T,y]of Object.entries(n)){const g=e==null?void 0:e.find(E=>{var _;return(_=E==null?void 0:E.customUpperCode)==null?void 0:_.includes(T)}),N=ve(y.toString(),g,r,f);N[T]&&(Object.assign(f,N),h=!1),d||(d=Object.keys(f).find(E=>f[E])??null)}if(c(f),d&&a.current){const T=a.current.elements.namedItem(d);T==null||T.focus()}return h},[i,e,n,r]);ie(()=>{if(e!=null&&e.length){const{initialData:h,errorList:f}=Jt(e);u(d=>({...h,...d})),c(f)}},[JSON.stringify(e)]);const l=F(async h=>{const f=h.target,d=!Yt.some(T=>f.classList.contains(T));!s.current&&d&&(await nt(0),s.current=!0)},[]),A=F(h=>{const{name:f,value:d,type:T,checked:y}=h==null?void 0:h.target,g=T==="checkbox"?y:d;u(_=>({..._,[f]:g}));const N=e==null?void 0:e.find(_=>{var b;return(b=_==null?void 0:_.customUpperCode)==null?void 0:b.includes(f)}),E={...i};if(N){const _=ve(g.toString(),N,r,E);_&&Object.assign(E,_),c(E)}},[e,i,r]),p=F(h=>{const{name:f,value:d,type:T,checked:y}=h==null?void 0:h.target,g=T==="checkbox"?y:d,N=e==null?void 0:e.find(E=>E.customUpperCode===f);if(N){const E={...i},_=ve(g.toString(),N,r,E);_&&Object.assign(E,_),c(E)}},[i,e,r]),w=F(h=>{h.preventDefault();const f=m();t==null||t(h,f)},[m,t]);return{formData:n,errors:i,formRef:a,handleChange:A,handleBlur:p,handleSubmit:w,handleFocus:l}};var le=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(le||{});const Qe=e=>{const t={errorKey:"",defaultErrorMessage:""};if(!e)return t;const r=e.indexOf(V);return r===-1?t:{errorKey:e.substring(0,r).trim(),defaultErrorMessage:e.substring(r+V.length).trim()}},pe=de(({item:e,errorConfig:t,className:r,itemClassName:a,loading:s,children:n})=>{const{errorKey:u,defaultErrorMessage:i}=Qe(t),c=G(`Auth.FormText.${u}.${e.code}`)[e.code];let m="";return i.length&&(m=c||i),o(Re,{error:m,className:re([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${r}--${e.id}`,disabled:s||e.disabled,children:n},e.id)}),je=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,onFocus:n,className:u,itemClassName:i,loading:c})=>o(pe,{item:e,errorConfig:r,className:u,itemClassName:i,loading:c,children:o(ot,{type:"text",name:e.customUpperCode,value:t??e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,autocomplete:e.autocomplete,onBlur:a,onChange:s,onFocus:n})})),Ge=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>{var m;const c=(m=e.options.find(l=>l.isDefault))==null?void 0:m.value;return o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(st,{name:e.customUpperCode,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:a,handleSelect:s,defaultValue:c??t??e.defaultValue,value:c??t??e.defaultValue})})}),er=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(it,{type:"text",name:e.customUpperCode,value:t||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s,disabled:i||e.disabled})})),tr=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(Se,{name:e.customUpperCode,checked:t||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s})})),rr=de(({item:e,valueMessage:t,errorConfig:r,onBlur:a,onChange:s,className:n,itemClassName:u,loading:i})=>o(pe,{item:e,errorConfig:r,className:n,itemClassName:u,loading:i,children:o(ut,{name:e.customUpperCode,value:t??e.defaultValue,label:`${e.label} ${e.required?"*":""}`,onBlur:a,onChange:s})})),ar=({slots:e,item:t,handleOnChange:r,handleOnBlur:a,handleOnFocus:s,errorConfig:n,errors:u})=>{const{errorKey:i,defaultErrorMessage:c}=Qe(n),m=G(`Auth.FormText.${i}.${t.code}`)[t.code];let l="";c.length&&(l=m||c);const A={inputName:t.customUpperCode,handleOnChange:r,handleOnBlur:a,handleOnFocus:s,errorMessage:l,errors:u,config:t};return o(D,{"data-testid":`signUpFormInput_${t.code}`,name:`SignUpFormInput_${t.code}`,slot:e==null?void 0:e[`SignUpFormInput_${t.code}`],context:A},t.id)},Fe=de(({slots:e,name:t,loading:r,children:a,className:s="defaultForm",fieldsConfig:n=[],onSubmit:u,formSlot:i,...c})=>{const{formData:m,errors:l,formRef:A,handleChange:p,handleBlur:w,handleSubmit:h,handleFocus:f}=Qt({onSubmit:u,fieldsConfig:n}),d=`${s}__field`,T=R(Ae,{children:[n.map(g=>{const N=l==null?void 0:l[g.customUpperCode],E=m==null?void 0:m[g.customUpperCode],_=!!(e!=null&&e[`SignUpFormInput_${g.code}`]),b=o(ar,{slots:e,item:g,handleOnChange:p,handleOnBlur:w,handleOnFocus:f,errorConfig:N,errors:l});switch(g.fieldType){case le.TEXT:return _?b:g.options.length?o(Ge,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,onFocus:f,itemClassName:d,className:s,loading:r}):o(je,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,onFocus:f,itemClassName:d,className:s,loading:r});case le.MULTILINE:return _?b:o(je,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,onFocus:f,itemClassName:d,className:s,loading:r});case le.SELECT:return _?b:o(Ge,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,itemClassName:d,className:s,loading:r});case le.DATE:return _?b:o(er,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,itemClassName:d,className:s,loading:r});case le.BOOLEAN:return _?b:o(tr,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,itemClassName:d,className:s,loading:r});case le.TEXTAREA:return _?b:o(rr,{item:g,valueMessage:E,errorConfig:N,onBlur:w,onChange:p,itemClassName:d,className:s,loading:r});default:return null}}),a]}),y={...(i==null?void 0:i.context)??{},__formContentKey:[n.map(g=>g.id||g.code).join(","),JSON.stringify(l),JSON.stringify(m)].join("|")};return o("form",{onSubmit:h,name:t,ref:A,onFocus:f,...c,children:i?o(D,{name:i.name,slot:i.slot,context:y,className:s,"data-testid":i.dataTestId,children:T}):T})}),te=({type:e,buttonText:t,variant:r,className:a="",enableLoader:s=!1,onClick:n,style:u,icon:i,...c})=>{const m=F(p=>{n==null||n(p)},[n]),l=G({loadingLabel:"Auth.Button.loadingLabel"});return R(Pe,{icon:i,style:u,type:e,variant:r,className:re(["auth-button",a,s?"enableLoader":""]),onClick:m,loading:s,loadingLabel:l.loadingLabel,...c,children:[o("span",{className:"auth-button__text",children:t}),s?o("div",{className:"auth-button__wrapper",children:o("span",{className:"auth-button__loader"})}):null]})},nr=({label:e="",tooltip:t="",name:r="allowRemoteShoppingAssistance",defaultChecked:a=!1,onChange:s,className:n=""})=>{const[u,i]=x(!1),[c,m]=x(a),l=`${r}-tooltip`,A=({currentTarget:p})=>{const w=p.checked;m(w),s==null||s(w)};return o("div",{className:re(["remote-shopping-assistance-consent",n]),children:R("div",{className:"remote-shopping-assistance-consent__wrapper",children:[o(Re,{children:o(Se,{name:r,value:"true",placeholder:e,label:e,checked:c,onChange:A})}),t?R("div",{className:"remote-shopping-assistance-consent__info-container",children:[o("button",{type:"button",className:"remote-shopping-assistance-consent__info-icon",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocusIn:()=>i(!0),onFocusOut:()=>i(!1),"aria-describedby":u?l:void 0,"aria-label":t,children:"?"}),u?R("span",{className:"remote-shopping-assistance-consent__tooltip",id:l,role:"tooltip",children:[t,o("span",{className:"remote-shopping-assistance-consent__tooltip-arrow"})]}):null]}):null]})})};export{Ve as R,yt as S,fr as U,He as a,ze as b,gr as c,_r as d,Er as e,pr as i};
|
|
4
4
|
//# sourceMappingURL=components.js.map
|