import { u as useAtomValue, a as appConfig, r as reactExports, b as axios, j as jsxRuntimeExports, G as Grid, T as Tooltip, I as IconButton, R as RefreshIcon, B as Button, C as Container, c as CssBaseline, d as Box, e as Grow, F as FormControl, f as InputLabel, O as OutlinedInput, g as InputAdornment, h as FormHelperText, i as FormControlLabel, k as Checkbox, L as Link, H as HelpIcon, D as Dialog, l as DialogContent, m as DialogContentText, S as Slide } from "./index-D15x63tD.js";
import { A as AlertDialogSlide } from "./Alert-Bz9RX1jF.js";
import { C as CssTextField, V as VisibilityOff, a as Visibility, W as WhereNavigate } from "./SignIn-BbTs8zBq.js";
const Transition = reactExports.forwardRef(function Transition2(props, ref) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Slide, { direction: "up", ref, ...props });
});
function SignUpUMI() {
  var _a;
  const config = useAtomValue(appConfig);
  var pattern = new RegExp(
    /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
  );
  const PasswordPattern = new RegExp(/(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.])(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).*$/);
  document.title = "Регистрация";
  const [open, setOpen] = reactExports.useState(false);
  const [status, setStatus] = reactExports.useState(false);
  const [message, setMessage] = reactExports.useState("");
  const [password, setPassword] = reactExports.useState("");
  const [passwordSubmit, setPasswordSubmit] = reactExports.useState("");
  const [error, setError] = reactExports.useState("");
  const [email, setEmail] = reactExports.useState("");
  const [captcha, setCaptcha] = reactExports.useState("");
  const [DataCaptcha, setDataCapctha] = reactExports.useState({
    passed: config.lk.baseCaptcha === "0" ? true : false,
    color: ""
  });
  const [showpassword, setShowPassword] = reactExports.useState(false);
  const [checked, setChecked] = reactExports.useState(false);
  const [helperTextPassword, sethelperTextPassword] = reactExports.useState("");
  const [isRequestLoading, setIsRequestLoading] = reactExports.useState(false);
  const url = (_a = config.lk.url) == null ? void 0 : _a.signUP;
  const handleClickShowPassword = () => {
    setShowPassword(!showpassword);
  };
  reactExports.useEffect(() => {
    if (config.lk.baseCaptcha === "1") getCaptha();
  }, []);
  const getCaptha = (color) => {
    var _a2;
    axios.get((_a2 = config.lk.url) == null ? void 0 : _a2.captcha).then((res) => {
      setCaptcha("");
      setDataCapctha({
        img: "data:image/gif;base64," + res.data.RCDATA,
        ident: res.data.ident,
        passed: false,
        color: color ? color : ""
      });
    });
  };
  const sendCaptha = () => {
    var _a2;
    axios.get(`${(_a2 = config.lk.url) == null ? void 0 : _a2.captcha}?ident=${DataCaptcha.ident}&check=${captcha}`).then((res) => {
      if (res.data.result === "1") {
        setDataCapctha({ ...DataCaptcha, passed: true, color: "Успешно." });
      } else {
        getCaptha("Повторите ещё раз.");
      }
    });
  };
  const second = /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 10, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
    Grid,
    {
      container: true,
      direction: "column",
      justifyContent: "center",
      alignItems: "center",
      spacing: 1,
      style: {
        borderStyle: "solid",
        borderWidth: "1px",
        borderRadius: "4px",
        borderColor: "rgb(60, 91, 119)"
      },
      children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, style: { width: "100%", backgroundColor: "rgb(60, 91, 119)" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          "img",
          {
            src: DataCaptcha.img,
            style: {
              borderStyle: "solid",
              borderWidth: "1px",
              borderColor: "rgb(236, 236, 236)",
              width: "97%"
            }
          }
        ) }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, direction: "row", justifyContent: "center", alignItems: "center", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title: "Обновить текст на картинке", placement: "left", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
            IconButton,
            {
              onClick: () => {
                getCaptha();
              },
              children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshIcon, { fontSize: "small" })
            }
          ) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, sx: { pb: 1, pt: 1 }, style: { width: "179px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
            CssTextField,
            {
              size: "small",
              id: "captha",
              name: "captha",
              value: captcha,
              sx: { ".MuiInputLabel-outlined": { fontSize: "12px" } },
              label: "Введите текст с картинки",
              helperText: DataCaptcha.color,
              onChange: (e) => {
                setCaptcha(e.target.value);
              }
            }
          ) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Grid,
            {
              item: true,
              sx: { p: 1 },
              style: {
                // width: "100%",
                display: "flex",
                justifyContent: "center"
              },
              children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                Button,
                {
                  style: {
                    backgroundColor: "#3c5b77",
                    textTransform: "none"
                  },
                  size: "small",
                  variant: "contained",
                  onClick: sendCaptha,
                  children: "Отправить"
                }
              )
            }
          )
        ] })
      ]
    }
  ) });
  const handleMouseDownPassword = (event) => {
    event.preventDefault();
  };
  const handleChangeCheckBox = (event) => {
    setChecked(event.target.checked);
    if (error.search(event.target.id) !== -1) {
      setError(error.replace(event.target.id, ""));
    }
  };
  const handleClose = () => {
    setOpen(false);
    if (status === true) {
      window.history.back();
    }
  };
  const unableError = (event) => {
    const name = event.target.id;
    if (error.search(name) !== -1) {
      setError(error.replace(name, ""));
    }
  };
  const handleSubmit = (event) => {
    event.preventDefault();
    const data = new FormData(event.currentTarget);
    let errors = "";
    let SignUpData = {
      regcode: data.get("regcode"),
      login: data.get("login"),
      email: data.get("email"),
      password: data.get("password")
    };
    if (!checked) {
      errors += "checkbox";
      setError(errors);
    }
    for (const [key, value] of Object.entries(SignUpData)) {
      if (value === "" || value === void 0) {
        if (key !== "MiddleName") {
          errors += key;
          setError(errors);
        }
      }
      if (key === "email" && pattern.test(email) === false) {
        errors += key;
        setError(errors);
      }
    }
    if (helperTextPassword !== "") {
      return;
    }
    if (errors === "") {
      setIsRequestLoading(true);
      axios.post(url, JSON.stringify(SignUpData)).then((response) => {
        setIsRequestLoading(false);
        if (response.data["status"] === "ok") {
          setStatus(true);
          setMessage(response.data["message"]);
        } else {
          setStatus(false);
          setMessage(response.data["status"]);
        }
        setOpen(true);
      });
    }
  };
  const handleChange = (event) => {
    setEmail(event.target.value);
  };
  const handleChangePassword = (event, passtoCheck) => {
    let errorLocal = error;
    if (event.target.id === "password") {
      errorLocal.replaceAll("password", "");
      if (!PasswordPattern.test(event.target.value)) {
        errorLocal += "password";
        sethelperTextPassword(
          "По валидации пароля минимум 8 символов, 1 цифра, латинская буква верхнего и буква нижнего регистра."
        );
      } else {
        if (event.target.value !== passwordSubmit) {
          sethelperTextPassword("Пароли должны совпадать!");
        } else {
          sethelperTextPassword("");
        }
      }
      setPassword(event.target.value);
    } else if (event.target.id === "passwordSubmit") {
      errorLocal.replaceAll("passwordSubmit", "");
      if (password !== event.target.value) {
        errorLocal += "passwordSubmit";
        sethelperTextPassword("Пароли должны совпадать!");
      } else {
        sethelperTextPassword("");
      }
      setPasswordSubmit(event.target.value);
    }
    setError(errorLocal);
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { component: "main", maxWidth: "xs", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CssBaseline, {}),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(
      Box,
      {
        sx: {
          marginTop: 8,
          display: "flex",
          flexDirection: "column",
          alignItems: "center"
        },
        children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: "logo.png", style: { width: config.lk.baseWidthLogo ? config.lk.baseWidthLogo : "45%" } }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { component: "form", noValidate: true, onSubmit: handleSubmit, sx: { mt: 0.8 }, autoComplete: "off", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, spacing: 2, justifyContent: "center", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 200, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                CssTextField,
                {
                  fullWidth: true,
                  id: "regcode",
                  label: "Регистрационный код",
                  name: "regcode",
                  error: error.search("regcode") !== -1,
                  helperText: error.search("regcode") !== -1 ? "Заполните поле" : "",
                  onChange: unableError
                }
              ) }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 200, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                CssTextField,
                {
                  fullWidth: true,
                  id: "login",
                  label: "Логин",
                  name: "login",
                  error: error.search("login") !== -1,
                  helperText: error.search("login") !== -1 ? "Заполните поле" : "",
                  onChange: unableError
                }
              ) }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 300, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
                FormControl,
                {
                  fullWidth: true,
                  variant: "outlined",
                  sx: {
                    "& .MuiOutlinedInput-root": {
                      "&.Mui-focused fieldset": { borderColor: "#3c5b77" }
                    }
                  },
                  children: [
                    /* @__PURE__ */ jsxRuntimeExports.jsx(InputLabel, { htmlFor: "password", sx: { "&.Mui-focused": { color: "#3c5b77" } }, children: "Пароль" }),
                    /* @__PURE__ */ jsxRuntimeExports.jsx(
                      OutlinedInput,
                      {
                        type: showpassword ? "text" : "password",
                        value: password,
                        fullWidth: true,
                        id: "password",
                        label: "Пароль",
                        name: "password",
                        error: helperTextPassword !== "",
                        onChange: (e) => {
                          handleChangePassword(e);
                          unableError(e);
                        },
                        endAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                          IconButton,
                          {
                            "aria-label": "toggle password visibility",
                            onClick: handleClickShowPassword,
                            onMouseDown: handleMouseDownPassword,
                            edge: "end",
                            children: showpassword ? /* @__PURE__ */ jsxRuntimeExports.jsx(VisibilityOff, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(Visibility, {})
                          }
                        ) })
                      }
                    ),
                    /* @__PURE__ */ jsxRuntimeExports.jsx(FormHelperText, { children: helperTextPassword })
                  ]
                }
              ) }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 300, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
                FormControl,
                {
                  fullWidth: true,
                  variant: "outlined",
                  sx: {
                    "& .MuiOutlinedInput-root": {
                      "&.Mui-focused fieldset": { borderColor: "#3c5b77" }
                    }
                  },
                  children: [
                    /* @__PURE__ */ jsxRuntimeExports.jsx(InputLabel, { htmlFor: "passwordSubmit", sx: { "&.Mui-focused": { color: "#3c5b77" } }, children: "Подтвердите пароль" }),
                    /* @__PURE__ */ jsxRuntimeExports.jsx(
                      OutlinedInput,
                      {
                        type: showpassword ? "text" : "password",
                        fullWidth: true,
                        value: passwordSubmit,
                        id: "passwordSubmit",
                        label: "Подтвердите пароль",
                        name: "passwordSubmit",
                        error: helperTextPassword !== "",
                        onChange: (e) => {
                          handleChangePassword(e);
                          unableError(e);
                        },
                        endAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton, { onClick: handleClickShowPassword, onMouseDown: handleMouseDownPassword, edge: "end", children: showpassword ? /* @__PURE__ */ jsxRuntimeExports.jsx(VisibilityOff, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(Visibility, {}) }) })
                      }
                    )
                  ]
                }
              ) }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, sm: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 250, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                CssTextField,
                {
                  value: email,
                  onChange: handleChange,
                  fullWidth: true,
                  id: "email",
                  label: "E-mail",
                  name: "email",
                  error: error.search("email") !== -1,
                  helperText: error.search("email") !== -1 ? "Заполните поле" : ""
                }
              ) }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 500, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                FormControlLabel,
                {
                  style: {
                    color: error.search("checkbox") !== -1 ? "red" : ""
                  },
                  control: /* @__PURE__ */ jsxRuntimeExports.jsx(
                    Checkbox,
                    {
                      style: {
                        color: error.search("checkbox") !== -1 ? "red" : "#07579f"
                      },
                      checked,
                      onChange: handleChangeCheckBox,
                      id: "checkbox"
                    }
                  ),
                  label: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Я согласен на обработку персональных данных (настоящим подтверждаю, что в случае регистрации мною третьих лиц, предоставляю персональные данные с их согласия)" })
                }
              ) }) }),
              config.lk.baseCaptcha === "0" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}) : second
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialogSlide, { setStatus, message, status, open }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 510, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
              Button,
              {
                style: { backgroundColor: "#3c5b77", textTransform: "none" },
                type: "submit",
                fullWidth: true,
                variant: "contained",
                sx: { mt: 3, mb: 2 },
                disabled: !DataCaptcha.passed || isRequestLoading,
                children: "Зарегистрироваться"
              }
            ) }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Grow, { in: true, timeout: 510, style: { transformOrigin: "0 0 0" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Grid, { container: true, justifyContent: "space-between", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: WhereNavigate(), className: "LinkLK", children: "Уже есть учётная запись? Войти" }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                Tooltip,
                {
                  arrow: true,
                  title: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
                    /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "По вопросам регистрации в личном кабинете Вы можете обратиться по телефону:" }),
                    /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
                    "- по договорам о размещении объектов: 435-69-31;",
                    /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
                    "- по договорам аренды имущества муниципальной казны: 435-69-38;",
                    /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
                    "- по договорам аренды нежилого фонда: 435-69-03, 435-69-02;",
                    /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
                    "- по договорам аренды земли : 435-69-29, 435-69-30."
                  ] }),
                  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                    HelpIcon,
                    {
                      fontSize: "small",
                      style: {
                        color: "rgb(60, 91, 119)"
                        // fontSize: "100%",
                      }
                    }
                  )
                }
              ) })
            ] }) })
          ] })
        ]
      }
    ),
    /* @__PURE__ */ jsxRuntimeExports.jsx(
      Dialog,
      {
        open,
        TransitionComponent: Transition,
        keepMounted: true,
        onClose: handleClose,
        "aria-describedby": "alert-dialog-slide-description",
        children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialogContentText, { id: "alert-dialog-slide-description", children: message }) })
      }
    )
  ] });
}
export {
  SignUpUMI as default
};
//# sourceMappingURL=SignUpUMI-oXBpHd2G.js.map
