const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_types = require("./types.js");
const require_locales = require("./locales.js");
const require_EmailSettingsContent = require("./components/EmailSettingsContent.js");
const require_PhoneSettingsContent = require("./components/PhoneSettingsContent.js");
const require_DefaultSettingsContent = require("./components/DefaultSettingsContent.js");
const require_PasswordRulesSettingsContent = require("./components/PasswordRulesSettingsContent.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("./SettingsDrawer.less");
//#region src/components/authentication/admin/AuthMethods/SettingsDrawer.tsx
_pisell_utils.locales.init(require_locales.default, localStorage.getItem("umi_locale") || "en");
const SettingsDrawer = ({ open, method, onClose, onSave, mode = "auth-methods", initialSettings }) => {
	const [currentSettings, setCurrentSettings] = react.default.useState(null);
	const handleSave = () => {
		if (currentSettings) onSave === null || onSave === void 0 || onSave(currentSettings);
		onClose();
	};
	const handleCancel = () => {
		onClose();
	};
	const getDrawerTitle = () => {
		if (!method) return _pisell_utils.locales.getText("auth.email.settings");
		if (method.type === require_types.AuthMethodType.EMAIL) return _pisell_utils.locales.getText("auth.email.settings");
		if (method.type === require_types.AuthMethodType.PHONE) return _pisell_utils.locales.getText("auth.phone.settings");
		if (method.type === require_types.AuthMethodType.PASSWORD_RULES) return _pisell_utils.locales.getText("auth.password.settings");
		return `${method.title} Settings`;
	};
	const handleSettingsChange = (settings) => {
		setCurrentSettings(settings);
		console.log("Settings changed:", settings);
	};
	const renderContent = () => {
		if (!method) return null;
		switch (method.type) {
			case require_types.AuthMethodType.EMAIL: return /* @__PURE__ */ react.default.createElement(require_EmailSettingsContent.default, {
				initialSettings,
				onSettingsChange: handleSettingsChange
			});
			case require_types.AuthMethodType.PHONE: return /* @__PURE__ */ react.default.createElement(require_PhoneSettingsContent.default, {
				initialSettings,
				onSettingsChange: handleSettingsChange
			});
			case require_types.AuthMethodType.PASSWORD_RULES: return /* @__PURE__ */ react.default.createElement(require_PasswordRulesSettingsContent.default, {
				initialSettings,
				onSettingsChange: handleSettingsChange
			});
			default:
				if (mode === "setting-list") return /* @__PURE__ */ react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ react.default.createElement("div", {
					className: "settings-section-description",
					style: {
						padding: "20px 0",
						color: "#8c8c8c"
					}
				}, _pisell_utils.locales.getText("auth.settings.no.additional")));
				return /* @__PURE__ */ react.default.createElement(require_DefaultSettingsContent.default, {
					method,
					onSettingsChange: handleSettingsChange
				});
		}
	};
	return /* @__PURE__ */ react.default.createElement(antd.Drawer, {
		title: getDrawerTitle(),
		placement: "right",
		width: 640,
		open,
		onClose: handleCancel,
		maskClosable: true,
		keyboard: true,
		footer: /* @__PURE__ */ react.default.createElement("div", { className: "drawer-footer" }, /* @__PURE__ */ react.default.createElement(antd.Button, { onClick: handleCancel }, _pisell_utils.locales.getText("auth.button.cancel")), /* @__PURE__ */ react.default.createElement(antd.Button, {
			type: "primary",
			onClick: handleSave,
			style: { marginLeft: 8 }
		}, _pisell_utils.locales.getText("auth.button.save")))
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: "settings-drawer-content",
		onClick: (e) => e.stopPropagation()
	}, renderContent()));
};
//#endregion
exports.default = SettingsDrawer;
