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/plus/saasDevice/appDevicePlanning/modules/workAreas/components/WorkAreaModal/index.tsx
var WorkAreaModal_exports = {};
__export(WorkAreaModal_exports, {
  default: () => WorkAreaModal_default
});
module.exports = __toCommonJS(WorkAreaModal_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_types = require("../../../../model/types");
var WorkAreaModal = ({
  open,
  variant = "desktop",
  mode,
  record,
  submitting,
  getText,
  onCancel,
  onSubmit
}) => {
  const isPhoneVariant = variant === "phone";
  const [form] = import_antd.Form.useForm();
  (0, import_react.useEffect)(() => {
    if (!open) return;
    form.setFieldsValue({
      name: mode === "edit" ? (0, import_types.toLangDict)(record == null ? void 0 : record.name) : { ...import_types.EMPTY_I18N },
      description: mode === "edit" ? (0, import_types.toLangDict)(record == null ? void 0 : record.description) : { ...import_types.EMPTY_I18N }
    });
  }, [form, mode, open, record]);
  const handleOk = async () => {
    const values = await form.validateFields();
    onSubmit(values);
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open,
      title: getText(
        mode === "create" ? "pisell2.saas.device-planning.modal.create-title" : "pisell2.saas.device-planning.modal.edit-title"
      ),
      headerDivider: false,
      onCancel,
      okText: getText(
        mode === "create" ? "pisell2.saas.device-planning.modal.create" : "pisell2.saas.device-planning.modal.save"
      ),
      cancelText: getText("pisell2.saas.device-planning.modal.cancel"),
      okButtonProps: { loading: submitting, onClick: handleOk },
      cancelButtonProps: { disabled: submitting },
      destroyOnClose: true,
      maskClosable: false,
      width: 520,
      platform: isPhoneVariant ? "h5" : void 0,
      mobileModalHeight: isPhoneVariant ? "auto" : void 0,
      className: `saas-app-device-planning-workarea-modal saas-app-device-planning-workarea-modal--${variant}`
    },
    /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form, layout: "vertical", preserve: false }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "name",
        label: getText("pisell2.saas.device-planning.modal.name"),
        required: true,
        rules: [
          {
            validator: (0, import_types.validateI18nRequired)(
              getText("pisell2.saas.device-planning.modal.name-required")
            )
          }
        ]
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.BaseTranslation, { renderMode: "edit" })
    ), /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        name: "description",
        label: getText("pisell2.saas.device-planning.modal.description")
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.BaseTranslation, { renderMode: "edit", type: "textarea" })
    ))
  );
};
var WorkAreaModal_default = WorkAreaModal;
