import{i as C,k as x,av as D,j as e,aw as O,ax as w,c as N,ay as B,az as M,A as z,aA as F,B as H,aB as U,b as I,g as L,aC as G,aD as $,aE as _}from"./main-7700519c.js";import{P as Y,R as Q}from"./chunk-index-f9cec726.js";import{r as b}from"./chunk-react-caacd912.js";import{m as P,G as a,q as v,x as q,e as y,B as k,d as p,s as T,D as W,L as Z,I as J,o as K}from"./chunk-material-ui-241eb317.js";import{N as X,T as ee}from"./chunk-index-3cb6e55a.js";const V=P(t=>({passText:{"& p":{paddingInlineStart:0}},btnText:{padding:"16px 9px",borderRadius:16}}),{name:"EmailFormAuth"}),te=()=>{const t=V(),c=C(),r=x(n=>n.userAuth.LOGIN),h=x(n=>n.userAuth.PASSWORD),[s,{isLoading:u}]=D(),[g,S]=b.useState(""),o=n=>{const{target:i}=n;c(w({name:i.name,value:i.value}))},j=n=>{n.preventDefault(),s({LOGIN:r,PASSWORD:h}).then(i=>{var A,m,l,f;if(((A=i==null?void 0:i.data)==null?void 0:A.status)==="success"&&N("login",{email:r}),((m=i==null?void 0:i.data)==null?void 0:m.status)==="error"){const d=(l=i==null?void 0:i.data)==null?void 0:l.errors[0];S((f=d==null?void 0:d.message)==null?void 0:f.replace(/[a-zA-Z<>]/g,""))}})};return e.jsx("form",{onSubmit:j,children:e.jsxs(a,{container:!0,spacing:3,children:[e.jsx(a,{item:!0,xs:12,children:e.jsx(v,{type:"email",name:"LOGIN",disabled:u,value:r,fullWidth:!0,onChange:o,placeholder:"Email"})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(q,{disabled:u,error:!!g,name:"PASSWORD",value:h,fullWidth:!0,type:"password",onChange:o,placeholder:"Пароль",helperText:g,classes:{root:t.passText}})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(y,{type:"submit",disabled:u||!r.length,fullWidth:!0,color:"default",variant:"contained",children:"Авторизоваться"})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(y,{onClick:()=>c(O("restorePassword")),disabled:u,classes:{root:t.btnText},fullWidth:!0,variant:"text",children:"РЇ забыл пароль"})})]})})},se=P(t=>({authBtnWrapper:{"& > *:not(:first-child)":{marginLeft:20},paddingBottom:24},authBtnVariant:{padding:0,"&:hover":{backgroundColor:"unset",color:t.color.blue}},authBtnVariantActive:{color:t.color.blue},authRulesWrapper:{position:"static",left:0,bottom:0,zIndex:t.zIndex.drawer,padding:"16px 0"},authRules:{fontSize:t.typography.pxToRem(14)},backDrop:{zIndex:2e3,position:"absolute",backgroundColor:"rgba(255, 255, 255, 0.5)"}}),{name:"UserAuthScreen"});function ne({}){const t=se(),c=C(),r=x(n=>n.userAuth.authVariant),h=x(n=>{var i,A;return(A=(i=n.errors)==null?void 0:i.authForm)==null?void 0:A.phoneLoginValidation}),s=x(n=>n.userAuth.repeatSmsCode),u=x(n=>n.userAuth.phone),g=x(n=>n.userAuth.phoneMask),[S,{data:o,isLoading:j}]=B();return e.jsxs(e.Fragment,{children:[e.jsxs(k,{className:t.authBtnWrapper,children:[e.jsx(y,{onClick:()=>c(M("phone")),classes:{root:t.authBtnVariant,textPrimary:r==="phone"?t.authBtnVariantActive:""},variant:"text",children:"РїРѕ телефону"}),e.jsx(y,{onClick:()=>c(M("email")),classes:{root:t.authBtnVariant,textPrimary:r==="email"?t.authBtnVariantActive:""},variant:"text",children:"РїРѕ E-mail"})]}),r==="phone"&&e.jsx(Y,{phoneVal:u,phoneMask:g,smsTimeStamp:s,validatePhoneMsg:h,phoneForm:"authForm",disabled:j,onValidatePhone:n=>{},onChangeFlag:n=>{c(z(n)),c(F(n)),c(H())},onChangeInput:(n,i)=>{c(U({name:n,value:i}))},onSubmit:()=>{S({url:I.user.authSmsCode,PERSONAL_PHONE:u,...L({SITE_ID:"lid",bitrix_sessid:"bitrix_sessid"})})}}),r==="email"&&e.jsx(te,{})]})}function re({time:t,delay:c}){const[r,h]=b.useState(0),s=b.useRef(0),u=b.useRef(void 0),[g,S]=b.useState(!1);b.useState(!1);const[o,j]=b.useState(!1),n=()=>{u.current&&window.clearInterval(u.current)},i=()=>{S(!0)},A=()=>{s.current&&j(!0)};return b.useEffect(()=>{t&&(s.current=t,h(s.current))},[t]),b.useEffect(()=>{if(g&&(s.current=t,h(s.current),S(!1)),o&&(s.current+=s.current,h(s.current),j(!1)),!!s.current)return u.current=window.setInterval(()=>{s.current-=1,h(s.current),s.current||clearInterval(u.current)},c),()=>clearInterval(u.current)},[c,g,o]),{timeInterval:r,continueFunc:A,restartFunc:i,pauseFunc:n}}const ae=P(t=>({inputSms:{textAlign:"center"},resetSmsBtn:{padding:0,color:t.color.black60}}),{name:"SmsForm"}),oe=t=>{const{inputRef:c,...r}=t,h=x(s=>s.userAuth.codeMask);return e.jsx(X,{...r,ref:s=>{c(s?s.inputElement:null)},allowEmptyFormatting:!0,format:h,mask:" "})},ie=({})=>{const t=ae(),[c,{data:r,isLoading:h}]=G(),s=x(d=>d.userAuth.phone),u=x(d=>{var E,R;return(R=(E=d.errors)==null?void 0:E.authForm)==null?void 0:R.phoneInput}),[g]=B(),[S,o]=b.useState(""),{timeInterval:j,continueFunc:n,restartFunc:i,pauseFunc:A}=re({time:60,delay:1e3}),m=d=>{const{target:E}=d,R=E.value.replaceAll(/\s/g,"");o(R)},l=(r==null?void 0:r.status)==="error",f=()=>{c({url:I.user.authByPhone,PERSONAL_PHONE:s,SMS_CODE:S,...L({SITE_ID:"lid",bitrix_sessid:"bitrix_sessid"})}).then(d=>{d.data.status==="success"&&N("login",{phone:s})})};return e.jsxs(a,{container:!0,spacing:3,children:[e.jsxs(a,{item:!0,xl:12,children:[e.jsx(p,{component:"p",variant:"body1",color:"secondary",children:"РњС‹ отправили SMS СЃ РєРѕРґРѕРј РЅР° номер"}),e.jsx(p,{component:"p",children:s})]}),e.jsxs(a,{item:!0,xs:12,children:[e.jsx(v,{value:S,fullWidth:!0,disabled:h,placeholder:"_ _ _ _",classes:{input:t.inputSms},onChange:m,inputComponent:oe}),l&&e.jsx(p,{style:{color:"red"},children:"неверный РєРѕРґ!"}),e.jsx(y,{onClick:()=>f(),style:{margin:"10px 0 0 0"},type:"submit",fullWidth:!0,color:"default",variant:"contained",children:"Продолжить"})]}),u&&e.jsx(a,{item:!0,xl:12,children:e.jsx(p,{variant:"body1",color:"error",children:u})}),e.jsx(a,{item:!0,xl:12,children:j>0?e.jsxs(p,{component:"p",variant:"body1",color:"secondary",children:["РєРѕРґ отправлен, запросить повторный можно через"," ",e.jsxs(p,{component:"span",children:[j," секунд"]})]}):e.jsx(y,{classes:{root:t.resetSmsBtn},color:"default",variant:"text",onClick:()=>{g({url:I.user.authSmsCode,PERSONAL_PHONE:s,...L({SITE_ID:"lid",bitrix_sessid:"bitrix_sessid"})}),i()},children:"отправить повторно"})})]})},ce=()=>{const t=V(),c=C(),r=x(l=>l.userRegister.formData),h=x(l=>l.userAuth.phone),s=x(l=>l.userAuth.LOGIN),u=x(l=>l.userRegister.phoneMask),[g,{isLoading:S}]=$(),o=x(l=>l.errors.errors),j=S||r.confirmation!=="Y",n=h.length?h:r.PERSONAL_PHONE,i=s.length?s:r.EMAIL,A=()=>{g({...r,PERSONAL_PHONE:n,EMAIL:i}).then(l=>{l.data.status==="success"&&N("sign_up",{email:i,phone:n})})},m=l=>{const{target:f}=l;let d;f.type==="checkbox"?d=f.checked?"Y":"N":d=f.value,c(_({name:f.name,value:d}))};return e.jsxs(a,{container:!0,spacing:3,children:[e.jsx(a,{item:!0,xs:12,children:e.jsx(v,{name:"EMAIL",onChange:m,disabled:s.length>=6,value:i,fullWidth:!0,placeholder:"E-mail"})}),(o==null?void 0:o.EMAIL)&&e.jsx(a,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"error",children:o.EMAIL})}),e.jsx(a,{item:!0,xs:6,children:e.jsx(v,{name:"LAST_NAME",onChange:m,value:r.LAST_NAME,fullWidth:!0,placeholder:"Фамилия"})}),e.jsx(a,{item:!0,xs:6,children:e.jsx(v,{name:"NAME",onChange:m,value:r.NAME,fullWidth:!0,placeholder:"РРјСЏ"})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(ee,{onSelectFlag:l=>c(F(l)),inputMask:u,inputValue:n,inputName:"PERSONAL_PHONE",isDisabled:h.length>=18,onInputChange:(l,f,d)=>{c(_({name:f,value:d}))}})}),(o==null?void 0:o.PERSONAL_PHONE)&&e.jsx(a,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"error",children:o==null?void 0:o.PERSONAL_PHONE})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(v,{name:"PASSWORD",value:r.PASSWORD,onChange:m,fullWidth:!0,type:"password",placeholder:"Пароль"})}),(o==null?void 0:o.PASSWORD)&&e.jsx(a,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"error",children:o.PASSWORD})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(v,{name:"CONFIRM_PASSWORD",onChange:m,fullWidth:!0,type:"password",placeholder:"Еще раз пароль"})}),(o==null?void 0:o.CONFIRM_PASSWORD)&&e.jsx(a,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"error",children:o.CONFIRM_PASSWORD})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(T,{control:e.jsx(W,{name:"subscribe",checked:r.subscribe==="Y",onChange:m,color:"primary"}),label:"Хочу получать новости Рѕ скидках Рё спецпредложениях"})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(T,{control:e.jsx(W,{name:"confirmation",checked:r.confirmation==="Y",onChange:m,color:"primary"}),label:`РЎ правилами Рё условиями работы интернет-магазина ознакомлен Рё согласен СЃ политикой конфиденциальности`})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(y,{onClick:A,disabled:j,fullWidth:!0,variant:"contained",color:"default",children:"Зарегистрироваться"})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(y,{onClick:()=>c(O("authScreen")),classes:{root:t.btnText},fullWidth:!0,variant:"text",children:"РЈ меня есть аккаунт"})})]})};function le({onUpdateScreen:t}){return e.jsxs(a,{container:!0,spacing:3,children:[e.jsx(a,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"secondary",children:"РњС‹ отправили РїРёСЃСЊРјРѕ СЃРѕ ссылкой для смены пароля РЅР° указанный Вами РїСЂРё регистрации адрес."})}),e.jsx(a,{item:!0,xs:12,children:e.jsx(y,{fullWidth:!0,variant:"contained",children:"Авторизоваться"})})]})}const ue=P(t=>({rulesText:{fontSize:t.typography.pxToRem(14),lineHeight:t.typography.pxToRem(20)},rulesTextLink:{color:t.color.black100,fontSize:t.typography.pxToRem(14)}}),{name:"RegisterRules"});function he(){const t=ue();return e.jsx(k,{children:e.jsxs(p,{color:"secondary",variant:"body2",component:"span",classes:{root:t.rulesText},children:["Нажимая «Продолжить», РІС‹ соглашаетесь РЅР° обработку ваших"," ",e.jsx(p,{component:"span",variant:"body2",children:e.jsx(Z,{classes:{root:t.rulesTextLink},href:"/information/policy-confidence/",underline:"none",target:"_blank",children:"персональных данных"})})]})})}const de=P(t=>({backBtn:{position:"absolute",left:24,top:24,padding:0}}),{name:"UserAuth"});function je(){const t=x(u=>u.userAuth.authScreen),c=C(),r=de(),h=t!=="authScreen"&&t!=="registration",s=()=>{c(O("authScreen"))};return e.jsxs(k,{display:"flex",flexDirection:"row",flexWrap:"wrap",alignContent:"space-between",height:"100%",children:[e.jsxs(k,{children:[h&&e.jsx(J,{classes:{root:r.backBtn},onClick:s,children:e.jsx(K,{color:"secondary"})}),t==="authScreen"&&e.jsx(ne,{}),t==="smsScreen"&&e.jsx(ie,{}),t==="restorePassword"&&e.jsx(Q,{infoMsg:"Отправим РЅР° вашу почту инструкцию РїРѕ смене пароля"}),t==="registration"&&e.jsx(ce,{}),t==="successChangeEmail"&&e.jsx(le,{})]}),t==="authScreen"&&e.jsx(he,{})]})}export{je as U,re as u};