import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import React, { useState } from "react";
import { Button, Form, Input } from "antd";
import { locales } from "@pisell/utils";
import "../index.less";
//#region src/plus/saasRegister/components/EntryEmail.tsx
const EntryEmail = (props) => {
	const [loading, setLoading] = useState(false);
	const { emailLabel = locales.getText("pisell-saas-register-email-label"), emailPlaceholder = locales.getText("pisell-saas-register-email-placeholder"), onVerifyEmail, buttonText = locales.getText("pisell-saas-register-button"), form } = props;
	const emailRules = [{
		required: true,
		message: locales.getText("pisell-saas-register-email-error")
	}, {
		type: "email",
		message: locales.getText("pisell-saas-register-email-error-valid")
	}];
	const _onClick = function() {
		var _ref = _asyncToGenerator(function* () {
			try {
				setLoading(true);
				const values = yield form.validateFields();
				const result = yield onVerifyEmail === null || onVerifyEmail === void 0 ? void 0 : onVerifyEmail(values.email);
				props.handleVerifyEmail(!!result);
			} catch (error) {
				console.error("handleVerifyEmail failed:", error);
			} finally {
				setLoading(false);
			}
		});
		return function _onClick() {
			return _ref.apply(this, arguments);
		};
	}();
	return /* @__PURE__ */ React.createElement("div", { className: "pisell-saas-register-form" }, /* @__PURE__ */ React.createElement("div", { className: "form-item-label" }, emailLabel), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "email",
		rules: emailRules
	}, /* @__PURE__ */ React.createElement(Input, {
		placeholder: emailPlaceholder,
		size: "large",
		className: "pisell-saas-register-input"
	})), /* @__PURE__ */ React.createElement(Button, {
		type: "primary",
		block: true,
		size: "large",
		loading,
		className: "pisell-saas-register-button",
		onClick: _onClick
	}, buttonText));
};
//#endregion
export { EntryEmail as default };
