import{aF as F,j as e,i as R,z as b,aw as k}from"./main-7700519c.js";import{r as u}from"./chunk-react-caacd912.js";import{G as n,d as p,x as B,e as g}from"./chunk-material-ui-241eb317.js";import{T as D}from"./chunk-index-3cb6e55a.js";function W({infoMsg:r}){const[o,j]=u.useState(""),[i,l]=u.useState(""),[a,S]=u.useState(""),[y,{isLoading:c}]=F(),E=async()=>{var d,x,m,h,f,s;const t=await y({useremail:o});if(((d=t==null?void 0:t.data)==null?void 0:d.status)==="success")return S((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:S,onChangeInput:y,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),y(T,C)},m=s=>{r&&r.length&&a(!0),S(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};