"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[55],{11:(e,a,t)=>{t.d(a,{a:()=>s});const s={accountWrapper:"qXeGpPSw",accountForm:"te7CAZQv",accountFormHeader:"f4fynuS_",accountTitle:"CZZ7NDmu",loginError:"qrsGJS4Z",messageError:"Xi3EMAjG",messageSuccess:"ncQvHM1f",accountFormAddress:"L0DnW04B",fieldsGroup:"CXuR8tOG",accountInputs:"ASip41tM",accountInput:"l0QekQFo",accountInputField:"_5m1fDGB",accountInputLabel:"IqibuG6w",accountInputError:"q5jlBe40",accountFooter:"Ion5fm0b",accountFooterLink:"ZnbNBlxs",loginLinkSecondary:"LUkLKGDg",accountButton:"dXdFogH1",accountButtonCenter:"M2GZLJwh",accountButtonFullWidth:"WkBk7vAa",accountButtonDisabled:"pZZht3dJ",accountButtonSecondary:"tiGBYEEt",accountButtonTertiary:"cNBbhsDX",accountButtons:"NAQeZAc6",buttonContent:"Js9SZWRC",buttonLoader:"JecoWbXv",spin:"yMF41ZyR",container:"VdYjDBT4",nav:"MNnJmn1N",addressCard:"NXDC3UD7",addressActions:"rKEskyqS",accountInputsFullWidth:"ihiTc9Ij"}},239:(e,a,t)=>{var s=t(0),r=t(11),n=t(45),o=t(1),c=t(54),i=t(2),l=t(38),u=t(10),m=t(46),d=t(61),p=t(204);function h(){const e=(0,u.g)(),a={firstName:"",lastName:"",email:"",password:""},[t,n]=(0,o.useState)(a),[h,v]=(0,o.useState)({}),[g,N]=(0,o.useState)(!1),[f,w]=(0,o.useState)(null),b=(0,o.useCallback)((()=>{const e={};return t.firstName.trim()||(e.firstName="First name is required."),t.lastName.trim()||(e.lastName="Last name is required."),t.email.trim()?(0,c.b)(t.email)||(e.email="Please enter a valid email."):e.email="Email is required.",t.password?(0,c.a)(t.password)||(e.password="Password must be at least 8 characters long and include at least one number, one uppercase letter, and one lowercase letter."):e.password="Password is required.",v(e),0===Object.keys(e).length}),[t]),y=(0,o.useCallback)((e=>a=>{const t=a.target.value;n((a=>Object.assign(Object.assign({},a),{[e]:t}))),v((a=>Object.assign(Object.assign({},a),{[e]:void 0}))),f&&w(null)}),[f]),x=(0,o.useCallback)((e=>{return s=this,r=void 0,c=function*(){var s,r,o,c;if(e.preventDefault(),b()){N(!0),w(null);try{const e=yield(0,i.getLazyState)("customerCreate",{email:t.email.trim(),password:t.password,firstName:t.firstName.trim(),lastName:t.lastName.trim()});if("error"===(null==e?void 0:e.status))return void w({type:"error",text:"Something went wrong. Try again"});if(null===(s=null==e?void 0:e.userErrors)||void 0===s?void 0:s.length)return void w({type:"error",text:e.userErrors[0].message});const u=new URLSearchParams(window.location.search),m=yield(0,i.getLazyState)("customerAccessTokenCreate",{email:t.email.trim(),password:t.password,return_to:null!==(r=u.get("return_to"))&&void 0!==r?r:void 0}),d=null===(o=null==m?void 0:m.data)||void 0===o?void 0:o.accessToken,p=null===(c=null==m?void 0:m.multipassLoginUrl)||void 0===c?void 0:c.url;if(d&&p)return(0,l.b)("customer_token",d,{expires:7}),void(window.location.href=p);w({type:"success",text:"Account created! You can now sign in."}),n(a)}catch(e){console.error("Signup failure:",e),w({type:"error",text:"Unexpected error. Please try again."})}finally{N(!1)}}},new((o=void 0)||(o=Promise))((function(e,a){function t(e){try{i(c.next(e))}catch(e){a(e)}}function n(e){try{i(c.throw(e))}catch(e){a(e)}}function i(a){var s;a.done?e(a.value):(s=a.value,s instanceof o?s:new o((function(e){e(s)}))).then(t,n)}i((c=c.apply(s,r||[])).next())}));var s,r,o,c}),[b,t]);return(0,s.jsxs)("div",{className:r.a.accountWrapper,children:[(0,s.jsx)("div",{className:r.a.accountFormHeader,children:(0,s.jsx)("h1",{children:"Create account"})}),f&&(0,s.jsxs)("div",{className:"error"===f.type?r.a.messageError:r.a.messageSuccess,children:["success"==f.type&&(0,s.jsx)(p.b,{}),f.text]}),(0,s.jsxs)("form",{className:r.a.accountForm,onSubmit:x,children:[(0,s.jsxs)("div",{className:r.a.accountInputs,children:[(0,s.jsx)(m.a,{label:"Email",name:"email",type:"email",placeholder:"Email",autocomplete:"email",value:t.email,onChange:y("email"),errormessage:h.email}),(0,s.jsx)(m.a,{label:"First Name",name:"firstName",type:"text",placeholder:"First Name",autocomplete:"given-name",value:t.firstName,onChange:y("firstName"),errormessage:h.firstName}),(0,s.jsx)(m.a,{label:"Last Name",name:"lastName",type:"text",placeholder:"Last Name",autocomplete:"family-name",value:t.lastName,onChange:y("lastName"),errormessage:h.lastName}),(0,s.jsx)(m.a,{label:"Password",name:"password",type:"password",placeholder:"Password",autocomplete:"current-password",value:t.password,onChange:y("password"),errormessage:h.password})]}),(0,s.jsx)("button",{type:"submit",className:`${r.a.accountButton} ${r.a.accountButtonCenter}`,disabled:g,children:(0,s.jsxs)("span",{className:r.a.buttonContent,children:[g&&(0,s.jsx)("span",{className:r.a.buttonLoader}),(0,s.jsx)("span",{children:"Create"})]})}),(0,s.jsx)("div",{className:r.a.accountFooter,children:(0,s.jsx)("a",{href:(0,d.a)(e("/account/login")),className:r.a.accountFooterLink,children:"Already have an account? Sign in"})})]})]})}(0,i.createEntrypoint)("account_form",(function({form_type:e}){return(0,s.jsxs)("div",{className:r.a.login,children:["login"===e&&(0,s.jsx)(n.a,{}),"register"===e&&(0,s.jsx)(h,{})]})}))}},e=>{e.O(0,[1,2,3,4,5,6,7,30,49],(()=>e(e.s=239))),e.O()}]);