import{aF as F,j as e,i as R,z as b,aw as k}from"./main-ac2fa4b1.js";import{r as u}from"./chunk-react-162a731f.js";import{G as n,e as p,y as B,f as g}from"./chunk-material-ui-42c43899.js";import{T as D}from"./chunk-index-a4bfef69.js";function W({infoMsg:r}){const[o,j]=u.useState(""),[i,l]=u.useState(""),[a,y]=u.useState(""),[S,{isLoading:c}]=F(),E=async()=>{var d,x,m,h,f,s;const t=await S({useremail:o});if(((d=t==null?void 0:t.data)==null?void 0:d.status)==="success")return y((m=(x=t==null?void 0:t.data)==null?void 0:x.data)==null?void 0:m.MESSAGE);if(((h=t==null?void 0:t.data)==null?void 0:h.status)==="error")return l((s=(f=t==null?void 0:t.data)==null?void 0:f.errors[0])==null?void 0:s.message)};return a?e.jsx(n,{container:!0,spacing:3,children:e.jsx(p,{children:a})}):e.jsxs(n,{container:!0,spacing:3,children:[r&&e.jsx(n,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"secondary",children:r})}),e.jsx(n,{item:!0,xs:12,children:e.jsxs("form",{onSubmit:function(t){t.preventDefault(),E()},children:[e.jsx(n,{item:!0,xs:12,style:{marginBlockEnd:18},children:e.jsx(B,{disabled:c,onChange:t=>j(t.target.value),fullWidth:!0,required:!0,placeholder:"E-mail",color:"secondary",type:"email",inputProps:{"aria-label":"email input",pattern:"[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,}$"},error:!!i,helperText:!!i&&i})}),e.jsx(n,{item:!0,xs:12,children:e.jsx(g,{disabled:c,fullWidth:!0,color:"default",variant:"contained",component:"button",type:"submit",children:"Продолжить"})})]})})]})}const v=({validatePhoneMsg:r,phoneVal:o,phoneMask:j,inputName:i,disabled:l,onValidatePhone:a,onChangeFlag:y,onChangeInput:S,onSubmit:c})=>{const E=R(),[t,d]=u.useState({});u.useEffect(()=>{r&&r.length&&a(!0)},[]);const x=(s,T,C)=>{r&&r.length&&a(!0),S(T,C)},m=s=>{r&&r.length&&a(!0),y(s)},h=()=>{if(!b(o))return d(s=>({...s,phone:"Некорректный формат телефона"}));E(k("smsScreen")),c()},f=s=>{if(s.code==="NumpadEnter"||s.code==="Enter"){if(s.preventDefault(),!b(o))return a(!1);c()}};return e.jsx("form",{autoComplete:"off",onKeyDown:f,children:e.jsxs(n,{container:!0,spacing:3,justifyContent:"space-between",children:[e.jsx(n,{item:!0,xs:12,children:e.jsx(D,{onSelectFlag:m,inputMask:j,isDisabled:l,inputValue:o,inputName:i||"phone",error:t,onInputChange:x})}),r&&e.jsx(n,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"error",children:r})}),e.jsx(n,{item:!0,xs:12,children:e.jsx(p,{variant:"body1",color:"secondary",children:"Мы отправим на номер SMS-сообщение с кодом подтверждения."})}),e.jsx(n,{item:!0,xs:12,children:e.jsx(g,{disabled:l,onClick:h,fullWidth:!0,color:"default",variant:"contained",children:"Продолжить"})})]})})};export{v as P,W as R};