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