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/authentication/admin/AuthMethods/SettingsDrawer.tsx
var SettingsDrawer_exports = {};
__export(SettingsDrawer_exports, {
  default: () => SettingsDrawer_default
});
module.exports = __toCommonJS(SettingsDrawer_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_utils = require("@pisell/utils");
var import_types = require("./types");
var import_components = require("./components");
var import_SettingsDrawer = require("./SettingsDrawer.less");
var import_locales = __toESM(require("./locales"));
import_utils.locales.init(import_locales.default, localStorage.getItem("umi_locale") || "en");
var SettingsDrawer = ({ open, method, onClose, onSave, mode = "auth-methods", initialSettings }) => {
  const [currentSettings, setCurrentSettings] = import_react.default.useState(null);
  const handleSave = () => {
    if (currentSettings) {
      onSave == null ? void 0 : onSave(currentSettings);
    }
    onClose();
  };
  const handleCancel = () => {
    onClose();
  };
  const getDrawerTitle = () => {
    if (!method) return import_utils.locales.getText("auth.email.settings");
    if (method.type === import_types.AuthMethodType.EMAIL) {
      return import_utils.locales.getText("auth.email.settings");
    }
    if (method.type === import_types.AuthMethodType.PHONE) {
      return import_utils.locales.getText("auth.phone.settings");
    }
    if (method.type === import_types.AuthMethodType.PASSWORD_RULES) {
      return import_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 import_types.AuthMethodType.EMAIL:
        return /* @__PURE__ */ import_react.default.createElement(
          import_components.EmailSettingsContent,
          {
            initialSettings,
            onSettingsChange: handleSettingsChange
          }
        );
      case import_types.AuthMethodType.PHONE:
        return /* @__PURE__ */ import_react.default.createElement(
          import_components.PhoneSettingsContent,
          {
            initialSettings,
            onSettingsChange: handleSettingsChange
          }
        );
      case import_types.AuthMethodType.PASSWORD_RULES:
        return /* @__PURE__ */ import_react.default.createElement(
          import_components.PasswordRulesSettingsContent,
          {
            initialSettings,
            onSettingsChange: handleSettingsChange
          }
        );
      default:
        if (mode === "setting-list") {
          return /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-description", style: { padding: "20px 0", color: "#8c8c8c" } }, import_utils.locales.getText("auth.settings.no.additional")));
        }
        return /* @__PURE__ */ import_react.default.createElement(
          import_components.DefaultSettingsContent,
          {
            method,
            onSettingsChange: handleSettingsChange
          }
        );
    }
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Drawer,
    {
      title: getDrawerTitle(),
      placement: "right",
      width: 640,
      open,
      onClose: handleCancel,
      maskClosable: true,
      keyboard: true,
      footer: /* @__PURE__ */ import_react.default.createElement("div", { className: "drawer-footer" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleCancel }, import_utils.locales.getText("auth.button.cancel")), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: handleSave, style: { marginLeft: 8 } }, import_utils.locales.getText("auth.button.save")))
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-drawer-content", onClick: (e) => e.stopPropagation() }, renderContent())
  );
};
var SettingsDrawer_default = SettingsDrawer;
