"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[32],{33:(e,a,t)=>{t.d(a,{a:()=>r});var n=t(0),s=t(11);const r=({label:e,name:a,type:t="text",options:r,placeholder:o,autocomplete:i,value:l,onChange:c,errormessage:u,required:d=!1})=>(0,n.jsxs)("div",{className:s.a.accountInput,children:[(0,n.jsxs)("label",{htmlFor:a,className:s.a.accountInputLabel,children:[e,d&&(0,n.jsx)("span",{children:"*"})]}),"select"===t?(0,n.jsxs)("select",{id:a,name:a,className:s.a.accountInputField,onChange:c,children:[l?(0,n.jsx)("option",{value:l,children:l}):(0,n.jsx)("option",{value:"",children:o}),(null!=r?r:[]).map(((e,a)=>(0,n.jsx)("option",{value:e,children:e},a)))]}):(0,n.jsx)("input",{id:a,type:t,name:a,placeholder:o,autoComplete:i,className:s.a.accountInputField,value:null!=l?l:void 0,onChange:c,"aria-invalid":!!u,"aria-errormessage":u}),(0,n.jsx)("p",{id:`${a}-error`,className:s.a.accountInputError,hidden:!u,"aria-live":"polite",children:u})]})},36:(e,a,t)=>{t.d(a,{a:()=>m});var n=t(0),s=t(2),r=t(1),o=t(18),i=t(40),l=t(11),c=t(33),u=t(10),d=function(e,a,t,n){return new(t||(t=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function i(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var a;e.done?s(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(o,i)}l((n=n.apply(e,a||[])).next())}))};function m({loginOnly:e,returnTo:a}){const t=(0,u.c)(),m=function(){const[e,a]=(0,r.useState)((()=>"undefined"!=typeof window&&"#recover"===window.location.hash));return(0,r.useEffect)((()=>{const e=()=>a("#recover"===window.location.hash);return window.addEventListener("hashchange",e),e(),()=>window.removeEventListener("hashchange",e)}),[]),e}(),h=!e&&m,p=(0,r.useMemo)((()=>h?"Reset password":"Sign in"),[h]),w=(0,r.useMemo)((()=>h?"We will send you an email to reset your password":""),[h]),[v,g]=(0,r.useState)({email:"",password:""}),[f,x]=(0,r.useState)({}),[j,y]=(0,r.useState)(!1),[b,N]=(0,r.useState)(null),C=(0,r.useCallback)((()=>{const e={};return v.email.trim()?(0,i.b)(v.email)||(e.email="Please enter a valid email."):e.email="Email is required.",h||v.password||(e.password="Password is required."),x(e),0===Object.keys(e).length}),[v,h]),S=(0,r.useCallback)((e=>a=>{const t=a.target.value;g((a=>Object.assign(Object.assign({},a),{[e]:t}))),x((a=>Object.assign(Object.assign({},a),{[e]:void 0}))),b&&N(null)}),[b]),k=(0,r.useCallback)((e=>d(this,void 0,void 0,(function*(){var t,n,r,i;if(e.preventDefault(),C()){y(!0),N(null);try{if(h){const e=yield(0,s.getLazyState)("initRecoverPassword",{email:v.email.trim()});if("success"!==(null==e?void 0:e.status))throw new Error("Something went wrong.");N({type:"success",text:"If that email exists in our system, you’ll receive reset instructions shortly."})}else{const e=new URLSearchParams(window.location.search),l=yield(0,s.getLazyState)("customerAccessTokenCreate",{email:v.email.trim(),password:v.password,return_to:null!==(t=null!=a?a:e.get("return_to"))&&void 0!==t?t:void 0});if(!l||(null==l?void 0:l.error))throw new Error(null!==(n=null==l?void 0:l.error)&&void 0!==n?n:"Something went wrong.");const c=null===(r=l.data)||void 0===r?void 0:r.accessToken,u=null===(i=l.multipassLoginUrl)||void 0===i?void 0:i.url;if(!c||!u)throw new Error("Authentication failed.");(0,o.b)("customer_token",c,{expires:7}),window.location.href=u}}catch(e){console.error("LoginForm error:",e),N({type:"error",text:"Something went wrong—please try again."})}finally{y(!1)}}}))),[v,h,C,a]);return(0,n.jsxs)("div",{className:l.a.accountWrapper,children:[(0,n.jsxs)("div",{className:l.a.accountFormHeader,children:[(0,n.jsx)("h1",{children:p}),w&&(0,n.jsx)("p",{children:w})]}),b&&(0,n.jsx)("div",{className:"error"===b.type?l.a.messageError:l.a.messageSuccess,children:b.text}),(0,n.jsxs)("form",{className:l.a.accountForm,onSubmit:k,children:[(0,n.jsxs)("div",{className:l.a.accountInputs,children:[(0,n.jsx)(c.a,{label:"Email",name:"email",type:"email",placeholder:"Email",autocomplete:"email",value:v.email,onChange:S("email"),errormessage:f.email}),!h&&(0,n.jsx)(c.a,{label:"Password",name:"password",type:"password",placeholder:"Password",autocomplete:"current-password",value:v.password,onChange:S("password"),errormessage:f.password})]}),h?(0,n.jsx)("button",{type:"submit",className:`${l.a.accountButton} ${l.a.accountButtonCenter}`,children:"Submit"}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"submit",className:`${l.a.accountButton} ${l.a.accountButtonCenter}`,disabled:j,children:(0,n.jsxs)("span",{className:l.a.buttonContent,children:[j&&(0,n.jsx)("span",{className:l.a.buttonLoader}),(0,n.jsx)("span",{children:"Login"})]})}),(0,n.jsxs)("div",{className:l.a.accountFooter,children:[(0,n.jsx)("a",{href:t("/account/register"),className:l.a.accountFooterLink,children:"Create account"}),(0,n.jsx)("a",{href:`${t("/account/login")}#recover`,className:l.a.accountFooterLink,children:"Forgot your password?"})]})]})]})]})}},40:(e,a,t)=>{function n(e){if(!e||"string"!=typeof e)return!1;if(!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]{1,63}@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,63})+$/.test(e))return!1;const[a,t]=e.split("@");return!(!a||!t||t.length>255)}function s(e){return"string"==typeof e&&e.length>=8&&/[a-z]/.test(e)&&/[A-Z]/.test(e)&&/\d/.test(e)}t.d(a,{a:()=>s,b:()=>n})}}]);