const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("../index.less");
//#region src/plus/saasRegister/components/EntryEmail.tsx
const EntryEmail = (props) => {
	const [loading, setLoading] = (0, react.useState)(false);
	const { emailLabel = _pisell_utils.locales.getText("pisell-saas-register-email-label"), emailPlaceholder = _pisell_utils.locales.getText("pisell-saas-register-email-placeholder"), onVerifyEmail, buttonText = _pisell_utils.locales.getText("pisell-saas-register-button"), form } = props;
	const emailRules = [{
		required: true,
		message: _pisell_utils.locales.getText("pisell-saas-register-email-error")
	}, {
		type: "email",
		message: _pisell_utils.locales.getText("pisell-saas-register-email-error-valid")
	}];
	const _onClick = function() {
		var _ref = require_asyncToGenerator._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.default.createElement("div", { className: "pisell-saas-register-form" }, /* @__PURE__ */ react.default.createElement("div", { className: "form-item-label" }, emailLabel), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "email",
		rules: emailRules
	}, /* @__PURE__ */ react.default.createElement(antd.Input, {
		placeholder: emailPlaceholder,
		size: "large",
		className: "pisell-saas-register-input"
	})), /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "primary",
		block: true,
		size: "large",
		loading,
		className: "pisell-saas-register-button",
		onClick: _onClick
	}, buttonText));
};
//#endregion
exports.default = EntryEmail;
