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/booking/forms/footer.tsx
var footer_exports = {};
__export(footer_exports, {
  default: () => footer_default
});
module.exports = __toCommonJS(footer_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_icons = require("@ant-design/icons");
var import_useSendModal = __toESM(require("./sendModal/useSendModal"));
var import_sendModal = __toESM(require("./sendModal"));
var import_utils = require("@pisell/utils");
var Footer = ({ state, reload }) => {
  var _a, _b, _c, _d, _e;
  const { open, setOpen, handleOpen, handleValuesChange, handleOk } = (0, import_useSendModal.default)(state == null ? void 0 : state.bookingId);
  const handleReload = async () => {
    await reload();
    import_materials.message.success(import_utils.locales.getText("pisell2.text.send-form-reminder-refresh"));
  };
  const isAllCompleted = (0, import_react.useMemo)(() => {
    var _a2;
    return Object.values(((_a2 = state == null ? void 0 : state.form) == null ? void 0 : _a2.value) || {}).every(
      (item) => item.length > 0
    );
  }, [(_a = state == null ? void 0 : state.form) == null ? void 0 : _a.value]);
  const defaultValues = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j;
    return {
      sendSms: !!((_b2 = (_a2 = state.client) == null ? void 0 : _a2.value) == null ? void 0 : _b2.phone),
      sendEmail: !!((_d2 = (_c2 = state.client) == null ? void 0 : _c2.value) == null ? void 0 : _d2.email),
      email: (_f = (_e2 = state.client) == null ? void 0 : _e2.value) == null ? void 0 : _f.email,
      phone: {
        code: (_h = (_g = state.client) == null ? void 0 : _g.value) == null ? void 0 : _h.country_calling_code,
        phone: (_j = (_i = state.client) == null ? void 0 : _i.value) == null ? void 0 : _j.phone
      }
    };
  }, [(_b = state.client) == null ? void 0 : _b.value]);
  if (!state.bookingId || !((_c = state == null ? void 0 : state.form) == null ? void 0 : _c.forms.length)) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-form-footer" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Tooltip, { title: import_utils.locales.getText("pisell2.text.send-form-reminder-tooltip") }, /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { size: "large", icon: /* @__PURE__ */ import_react.default.createElement(import_icons.ReloadOutlined, null), onClick: handleReload })), /* @__PURE__ */ import_react.default.createElement(import_materials.Button, { size: "large", block: true, type: "primary", onClick: handleOpen, disabled: isAllCompleted }, !isAllCompleted ? import_utils.locales.getText("pisell2.text.send-form-reminder") : import_utils.locales.getText("pisell2.text.send-form-reminder-completed")), /* @__PURE__ */ import_react.default.createElement(
    import_sendModal.default,
    {
      refreshKey: (_e = (_d = state.client) == null ? void 0 : _d.value) == null ? void 0 : _e.id,
      open,
      onCancel: () => setOpen(false),
      onOk: handleOk,
      onValuesChange: handleValuesChange,
      defaultValues
    }
  ));
};
var footer_default = Footer;
