var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/login/index.tsx
var login_exports = {};
__export(login_exports, {
  default: () => login_default
});
module.exports = __toCommonJS(login_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_index = require("./index.less");
var import_utils = require("@pisell/utils");
var import_locales = require("../../utils/locales");
var import_locales2 = __toESM(require("./locales"));
var Login = (props) => {
  const { title, style, onLogin } = props;
  const [loading, setLoading] = (0, import_react.useState)(false);
  const onFinish = (values) => {
    setLoading(true);
    onLogin && onLogin(values, (data) => {
      setLoading(false);
    });
  };
  (0, import_react.useMemo)(() => {
    console.log((0, import_locales.getLocale)(), "getLocale()");
    import_utils.locales.init(import_locales2.default, (0, import_locales.getLocale)());
  }, []);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__login-wrap", style }, /* @__PURE__ */ import_react.default.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__login-title" }, title || "Login"), /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { onFinish }, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "email",
      rules: [
        {
          required: true,
          message: import_utils.locales.getText("pisell2.text.email-placeholder")
        },
        {
          pattern: /^\w+((.\w+)|(-\w+))@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+).[A-Za-z0-9]+$/,
          message: import_utils.locales.getText("pisell2.text.email-error")
        }
      ]
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input,
      {
        placeholder: import_utils.locales.getText("pisell2.text.email-placeholder"),
        className: "pisell-lowcode__login-input pisell-lowcode__field-style"
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "password",
      rules: [
        {
          required: true,
          message: import_utils.locales.getText("pisell2.text.password-placeholder")
        },
        {
          pattern: new RegExp(/^[^\s]*$/, "g"),
          message: import_utils.locales.getText("pisell2.text.password-error")
        }
      ]
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input,
      {
        className: "pisell-lowcode__login-input pisell-lowcode__field-style",
        placeholder: import_utils.locales.getText("pisell2.text.password-placeholder"),
        type: "Password",
        autoComplete: "new-password"
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { noStyle: true }, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      className: "pisell-lowcode__login-button pisell-lowcode__field-style",
      type: "primary",
      htmlType: "submit",
      size: "large",
      loading
    },
    import_utils.locales.getText("pisell2.text.login")
  )))));
};
var login_default = Login;
