"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[14],{52:(e,a,t)=>{t.d(a,{a:()=>r});var n=t(0),s=t(17);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})]})},102:(e,a,t)=>{t.d(a,{a:()=>d});var n=t(0),s=t(1),r=t(2),o=t(33),i=t(82),l=t(17),c=t(52),u=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 d({loginOnly:e,returnTo:a}){const t=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}(),d=!e&&t,m=(0,r.useMemo)((()=>d?"Reset password":"Sign in"),[d]),h=(0,r.useMemo)((()=>d?"We will send you an email to reset your password":""),[d]),[p,w]=(0,r.useState)({email:"",password:""}),[v,g]=(0,r.useState)({}),[f,x]=(0,r.useState)(!1),[j,y]=(0,r.useState)(null),b=(0,r.useCallback)((()=>{const e={};return p.email.trim()?(0,i.b)(p.email)||(e.email="Please enter a valid email."):e.email="Email is required.",d||p.password||(e.password="Password is required."),g(e),0===Object.keys(e).length}),[p,d]),N=(0,r.useCallback)((e=>a=>{const t=a.target.value;w((a=>Object.assign(Object.assign({},a),{[e]:t}))),g((a=>Object.assign(Object.assign({},a),{[e]:void 0}))),j&&y(null)}),[j]),C=(0,r.useCallback)((e=>u(this,void 0,void 0,(function*(){var t,n,r,i;if(e.preventDefault(),b()){x(!0),y(null);try{if(d){const e=yield(0,s.getLazyState)("initRecoverPassword",{email:p.email.trim()});if("success"!==(null==e?void 0:e.status))throw new Error("Something went wrong.");y({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:p.email.trim(),password:p.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),y({type:"error",text:"Something went wrong—please try again."})}finally{x(!1)}}}))),[p,d,b,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:m}),h&&(0,n.jsx)("p",{children:h})]}),j&&(0,n.jsx)("div",{className:"error"===j.type?l.a.messageError:l.a.messageSuccess,children:j.text}),(0,n.jsxs)("form",{className:l.a.accountForm,onSubmit:C,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:p.email,onChange:N("email"),errormessage:v.email}),!d&&(0,n.jsx)(c.a,{label:"Password",name:"password",type:"password",placeholder:"Password",autocomplete:"current-password",value:p.password,onChange:N("password"),errormessage:v.password})]}),d?(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:f,children:(0,n.jsxs)("span",{className:l.a.buttonContent,children:[f&&(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:"/account/register",className:l.a.accountFooterLink,children:"Create account"}),(0,n.jsx)("a",{href:"/account/login#recover",className:l.a.accountFooterLink,children:"Forgot your password?"})]})]})]})]})}},82:(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})}}]);