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/info2/service/editService/index.tsx
var editService_exports = {};
__export(editService_exports, {
  default: () => editService_default
});
module.exports = __toCommonJS(editService_exports);
var import_Delete_wght300_24px = __toESM(require("@pisell/icon/es/Delete_wght300_24px"));
var import_utils = require("@pisell/utils");
var import_react = __toESM(require("react"));
var import_drawer = __toESM(require("../../../components/drawer"));
var import_model = require("../../../info/model");
var import_duration = __toESM(require("../../../materiels/duration"));
var import_Capacity = __toESM(require("./Capacity"));
var import_Resources = __toESM(require("./Resources"));
var import_antd = require("antd");
var import_index = require("./index.less");
var import_collapsibleList = __toESM(require("../../../components/collapsibleList"));
var import_utils2 = require("../../../components/collapsibleList/utils");
var import_index2 = require("./index.less");
var import_ahooks = require("ahooks");
var import_materials = require("@pisell/materials");
var import_utils3 = require("../../../../ticketBooking/utils");
var import_utils4 = require("../../../info/service2/utils");
var import_utils5 = require("../../../info/utils");
var import_utils6 = require("../../../utils");
var import_utilsByBooking = require("../../utilsByBooking");
var import_utils7 = require("../addService/utils");
var import_noteModal = __toESM(require("../../../../../plus/noteModal"));
var import_priceKeyboard = require("../../../../../pro/priceKeyboard");
var submitLock = false;
var Info = (_, ref) => {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
  const [form] = import_antd.Form.useForm();
  const useTotal = import_antd.Form.useWatch("total", form);
  const useResource = import_antd.Form.useWatch("resource", form);
  const useStartTime = import_antd.Form.useWatch("start_time", form);
  const useDuration = import_antd.Form.useWatch("duration", form);
  const useNote = import_antd.Form.useWatch("note", form);
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
  const resourcesRef = (0, import_react.useRef)(null);
  const isChangeTotal = (0, import_react.useRef)(false);
  const [noteModalOpen, setNoteModalOpen] = (0, import_react.useState)(false);
  const [open, setOpen] = (0, import_react.useState)(false);
  (0, import_react.useEffect)(() => {
    window.openBookingEditModal = () => {
      setOpen(true);
    };
    window.closeBookingEditModal = () => {
      setOpen(false);
    };
  }, []);
  const isNormalProduct = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2;
    if (!((_a2 = state == null ? void 0 : state.service) == null ? void 0 : _a2.cacheItem)) {
      return true;
    }
    return ((_b2 = state == null ? void 0 : state.service) == null ? void 0 : _b2.cacheItem) && (0, import_utils4.isNormalProductByDurationSchedule)((_c2 = state == null ? void 0 : state.service) == null ? void 0 : _c2.cacheItem);
  }, [(_a = state == null ? void 0 : state.service) == null ? void 0 : _a.cacheItem]);
  const getCurrentCacheItem = (0, import_ahooks.useMemoizedFn)((_cacheItem) => {
    let values = form.getFieldsValue();
    let _item = _cacheItem || state.service.cacheItem;
    return {
      ..._item,
      _extend: {
        ..._item == null ? void 0 : _item._extend,
        ...values
      }
    };
  });
  const currentResource = (0, import_react.useMemo)(() => {
    return null;
  }, []);
  const durationProps = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2;
    let _cacheItem = getCurrentCacheItem();
    const val2 = (0, import_utils7.getDurationProps)({
      cacheItem: _cacheItem,
      useStartTime,
      // currentResource,
      slice: (_c2 = (_b2 = (_a2 = state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c2.service_time
    });
    return val2;
  }, [
    // currentResource,
    state.service.cacheItem,
    useStartTime,
    useResource,
    (_d = (_c = (_b = state.bookingConfig) == null ? void 0 : _b.config) == null ? void 0 : _c.basic) == null ? void 0 : _d.service_time
  ]);
  const flexibleOption = (0, import_react.useMemo)(() => {
    const op = (0, import_utils7.getFlexibleOption)({
      durationProps
    });
    return op;
  }, [durationProps, import_utils.locales.locale]);
  const timeObj = (0, import_react.useMemo)(() => {
    const val2 = (0, import_utils7.getTimeObj)({
      durationProps,
      useStartTime,
      currentResource,
      state,
      useDuration
    });
    return val2;
  }, [
    durationProps,
    useStartTime,
    currentResource,
    (_g = (_f = (_e = state.bookingConfig) == null ? void 0 : _e.config) == null ? void 0 : _f.basic) == null ? void 0 : _g.service_time,
    useDuration
  ]);
  (0, import_react.useEffect)(() => {
    console.log("执行次数:于灵活时长的结束时间随");
    try {
      if (useDuration.indexOf("flexible_") == 0) {
        if (flexibleOption) {
          form.setFieldsValue({
            duration: flexibleOption.value
          });
        }
      }
    } catch (err) {
    }
  }, [useDuration, flexibleOption]);
  const handleDeleteProduct = (0, import_ahooks.useMemoizedFn)(() => {
    var _a2, _b2;
    if (state.channelDisabledEdit) {
      return;
    }
    let _list = [...state.service.value];
    let _id = (_a2 = state.service.cacheItem) == null ? void 0 : _a2._id;
    _list = _list.filter((d) => d._id !== _id);
    (_b2 = window.closeBookingEditModal) == null ? void 0 : _b2.call(window);
    dispatch({
      type: "setService",
      payload: {
        editModal: false,
        value: _list,
        edit: true,
        cacheItem: null
      }
    });
  });
  const getDiscount = () => {
    var _a2;
    let oPrice = Number(((_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend.origin_total) || 0);
    let cPrice = Number(useTotal || 0);
    let discount = "";
    if (cPrice === oPrice) {
      discount = import_utils.locales.getText("pisell2.text.status.no-discount");
    } else {
      discount = `${import_utils.locales.getText("pisell2.text.status.manual")} `;
      if (cPrice < oPrice) {
        discount += (0, import_utils.formatAmount)(cPrice - oPrice, 2, state.amountSymbol) + "";
      } else {
        discount += "+" + (0, import_utils.formatAmount)(cPrice - oPrice, 2, state.amountSymbol);
      }
    }
    form.setFieldsValue({ discount });
  };
  const onFinish = (values) => {
    var _a2, _b2, _c2, _d2;
    let isSuccess = (_a2 = resourcesRef.current) == null ? void 0 : _a2.check();
    if (isShowTimeAndResource && !isSuccess) {
      return;
    }
    if (submitLock) {
      return;
    }
    submitLock = true;
    setTimeout(() => {
      submitLock = false;
    }, 1500);
    let _list = [...state.service.value];
    let _item = {
      ...state.service.cacheItem,
      autoClose: false
    };
    let _extend = {
      ..._item._extend,
      other: {
        ...((_b2 = _item._extend) == null ? void 0 : _b2.other) || {},
        quantity: values.quantity
      },
      ...values
    };
    const { startDate, endDate } = (0, import_utils6.getServiceTimes)({ _extend });
    _extend.startDate = startDate;
    _extend.endDate = endDate;
    if (_extend.bundle_edit !== void 0) {
      _extend.bundle_edit = 1;
    }
    _item._extend = _extend;
    _item._time = (/* @__PURE__ */ new Date()).getTime();
    _item._serviceKey = (0, import_utils3.genServiceKey)(_item);
    let _id = _item == null ? void 0 : _item._id;
    if (!_list.some((d) => d._id === _id)) {
      const detail = (0, import_utils3.addService)(_list, _item, state);
      _list = detail.list;
    } else {
      if (isChangeTotal.current) {
        delete _item.discount_list;
      }
      _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
    }
    (0, import_utils6.deleteCacheParams)();
    console.log("_onFinish", _list);
    form.resetFields();
    if (!!((_c2 = state.service.cacheItem) == null ? void 0 : _c2.new)) {
      window.dispatchEvent(
        new CustomEvent("onAddNewService", {
          detail: {
            cacheItem: { ...state.service.cacheItem }
          }
        })
      );
    }
    (_d2 = window.closeBookingEditModal) == null ? void 0 : _d2.call(window);
    dispatch({
      type: "setService",
      payload: {
        editModal: false,
        addModal: false,
        value: _list,
        edit: true,
        cacheItem: null,
        changeService: false
      }
    });
  };
  const { run: setEditDataRun } = (0, import_ahooks.useDebounceFn)(
    (...params) => {
      setEditData(...params);
    },
    {
      wait: 50,
      leading: true,
      trailing: false
    }
  );
  const setEditData = (0, import_ahooks.useMemoizedFn)(
    (_cacheItem, open2, openProductDetail) => {
      console.timeEnd("handleChange");
      console.log("setEditDatasetEditData", _cacheItem, open2);
      isChangeTotal.current = false;
      let cacheItem = _cacheItem || state.service.cacheItem;
      let values = cacheItem._extend;
      const startTime2 = performance.now();
      console.log(startTime2, "startTime");
      form.resetFields();
      form.setFieldsValue(values);
      const endTime = performance.now();
      console.log(endTime - window.pp1, "打开商品5");
      console.log("执行时间", endTime - startTime2, values);
      setTimeout(() => {
      }, 20);
      if (openProductDetail) {
        setTimeout(() => {
          handleEdit({});
        }, 100);
      }
    }
  );
  const isReason = (0, import_react.useMemo)(() => {
    var _a2;
    let oPrice = Number(((_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend.origin_total) || 0);
    let cPrice = Number(useTotal || 0);
    return cPrice !== oPrice;
  }, [useTotal, (_i = (_h = state.service.cacheItem) == null ? void 0 : _h._extend) == null ? void 0 : _i.origin_total]);
  const getResources = () => {
    let res = (0, import_utils7.formatResources)({
      cacheItem: getCurrentCacheItem(),
      resourcesOrigin: state.service.cacheItem._data.resourcesOrigin
    });
    dispatch({
      type: "setService",
      payload: {
        cacheItem: {
          ...state.service.cacheItem,
          _data: {
            ...state.service.cacheItem._data,
            resources: res.list,
            resourceMaps: res.maps
          }
        }
      }
    });
    updateResourceErrors(res.maps);
  };
  const updateResourceErrors = (resourceMaps) => {
    let { resource: resource2 } = form.getFieldsValue();
    if (resource2) {
      let _resource = { ...resource2 };
      for (let form_id in _resource) {
        _resource[form_id] = _resource[form_id].map((d) => {
          var _a2, _b2;
          return {
            ...d,
            errors: (0, import_utilsByBooking.getErrorList)(
              (_b2 = (_a2 = resourceMaps == null ? void 0 : resourceMaps[form_id]) == null ? void 0 : _a2.renderListMaps) == null ? void 0 : _b2[d == null ? void 0 : d.relation_id],
              getCurrentCacheItem()
            )
          };
        });
      }
      form.setFieldsValue({
        resource: _resource
      });
      return _resource;
    }
  };
  (0, import_ahooks.useUpdateEffect)(() => {
    if (!state.service.cacheItem) {
      return;
    }
    if (useStartTime && useDuration && state.renderType !== "eventBooking") {
      getResources();
    }
  }, [
    useStartTime,
    useDuration,
    state.renderType,
    state.service.resourcesOrigin
  ]);
  (0, import_react.useEffect)(() => {
    if (state.isBookingCreatePage && state.service.editModal) {
      setEditDataRun(null);
    }
  }, [state.service.editModal, state.isBookingCreatePage]);
  (0, import_react.useEffect)(() => {
    getDiscount();
  }, [useTotal, (_k = (_j = state.service.cacheItem) == null ? void 0 : _j._extend) == null ? void 0 : _k.origin_total]);
  const bundles = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2, _d2;
    return ((_d2 = (_c2 = (_b2 = (_a2 = state.service) == null ? void 0 : _a2.cacheItem) == null ? void 0 : _b2._extend) == null ? void 0 : _c2.other) == null ? void 0 : _d2.bundle) || [];
  }, [(_o = (_n = (_m = (_l = state.service) == null ? void 0 : _l.cacheItem) == null ? void 0 : _m._extend) == null ? void 0 : _n.other) == null ? void 0 : _o.bundle]);
  const handleEdit = (0, import_ahooks.useMemoizedFn)((e) => {
    var _a2, _b2, _c2, _d2, _e2;
    const item = state.service.cacheItem;
    let values = form.getFieldsValue();
    const isSession = (0, import_utils6.isSessionProduct)(item);
    const sessionValue = {};
    if (isSession) {
      sessionValue.startEndTime = {
        startDate: (_a2 = item == null ? void 0 : item._extend) == null ? void 0 : _a2.start_date,
        endDate: (_b2 = item == null ? void 0 : item._extend) == null ? void 0 : _b2.end_date,
        duration: (_c2 = item == null ? void 0 : item._extend) == null ? void 0 : _c2.duration
      };
    }
    state.action({
      type: "pisell1.handleOpenProductModal",
      data: {
        id: item.id,
        date: state.date.value.format("YYYY-MM-DD"),
        showConfig: {
          option: true,
          session: isSession,
          variant: true,
          package: true,
          number: (0, import_utils3.getIsShowNumber)(item, state)
        },
        isOS: isSession,
        customer_id: (_e2 = (_d2 = state.client) == null ? void 0 : _d2.value) == null ? void 0 : _e2.id,
        value: {
          ...item._extend.other,
          ...sessionValue,
          quantity: values.quantity || item._extend.quantity
        }
      },
      callback: (e2, extension_type, detail) => {
        var _a3;
        const _detail = detail || item;
        const other = JSON.parse(JSON.stringify(e2));
        other.session = e2.session;
        let cacheItem = {
          ...item,
          ..._detail,
          product_id: item.id,
          _id: item == null ? void 0 : item._id,
          _key: e2.key,
          _extend: {
            ...item._extend,
            // 将当前表单的值覆盖进去
            ...values,
            quantity: (e2 == null ? void 0 : e2.quantity) || (values == null ? void 0 : values.quantity) || 1,
            // 覆盖选择的规格和套餐
            other
          },
          new: 0
        };
        let _total = (0, import_utils6.getProductTotalPrice)(cacheItem);
        cacheItem._extend.total = _total;
        try {
          cacheItem._extend.capacity = (0, import_utils7.setDefaultCapacitys)({
            capacitys: cacheItem._data.capacitys,
            cacheItem
          });
        } catch (err) {
        }
        const sessionDetail = (0, import_utils5.editSessionProduct)(cacheItem, e2.session);
        if (sessionDetail) {
          setTimeout(() => {
            form.setFieldsValue({
              start_time: sessionDetail.start_time,
              duration: sessionDetail.duration
            });
          }, 200);
        }
        cacheItem._extend.origin_total = _total;
        dispatch({
          type: "setService",
          payload: {
            cacheItem
          }
        });
        form.setFieldsValue({
          total: _total,
          capacity: (_a3 = cacheItem._extend) == null ? void 0 : _a3.capacity,
          quantity: (e2 == null ? void 0 : e2.quantity) || (values == null ? void 0 : values.quantity) || 1
        });
      }
    });
  });
  const handleChange = (0, import_ahooks.useMemoizedFn)((e) => {
    var _a2;
    if (state.channelDisabledEdit) {
      return;
    }
    form.resetFields();
    (_a2 = window.closeBookingEditModal) == null ? void 0 : _a2.call(window);
    dispatch({
      type: "setService",
      payload: {
        addModal: true,
        editModal: false
        //用于控制 添加商品 和 编辑服务弹窗的上下层级
        // changeService: true,
      }
    });
  });
  (0, import_react.useImperativeHandle)(ref, () => {
    return {
      init: setEditDataRun
    };
  });
  const handleTotalChange = (number) => {
    isChangeTotal.current = true;
  };
  const isShowTimeAndResource = (0, import_react.useMemo)(() => {
    if (state.renderType !== "eventBooking" && !isNormalProduct) {
      return true;
    }
    return false;
  }, [state.renderType, isNormalProduct]);
  const SelectTime = (_p = window.BaseMaterials) == null ? void 0 : _p.SelectTime;
  const isNoSpecAndPackage = (0, import_utilsByBooking.getIsNoSpecAndPackage)(state.service.cacheItem);
  const handleNoteConfirm = (noteValue) => {
    form.setFieldsValue({ note: noteValue });
    setNoteModalOpen(false);
  };
  const handleNoteDelete = () => {
    form.setFieldsValue({ note: "" });
    setNoteModalOpen(false);
  };
  const handleNoteCancel = () => {
    setNoteModalOpen(false);
  };
  console.log(isShowTimeAndResource, "isShowTimeAndResource");
  const productName = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2;
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "product_name" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name-wrap" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "current-service-info-name" }, ((_c2 = (_b2 = (_a2 = state.service) == null ? void 0 : _a2.cacheItem) == null ? void 0 : _b2._extend) == null ? void 0 : _c2.product_name) || "-"), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleEdit }, import_utils.locales.getText("pisell2.text.edit")), !state.isBookingCreatePage && /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: handleChange }, import_utils.locales.getText("pisell2.text.change"))), /* @__PURE__ */ import_react.default.createElement(
      import_collapsibleList.default,
      {
        style: { marginTop: bundles.length ? "8px" : 0 },
        list: bundles,
        renderItem: (item) => (0, import_utils2.renderBundles)(item, state.amountSymbol)
      }
    ))));
  }, [
    (_s = (_r = (_q = state.service) == null ? void 0 : _q.cacheItem) == null ? void 0 : _r._extend) == null ? void 0 : _s.product_name,
    bundles,
    state.amountSymbol,
    state.isBookingCreatePage
  ]);
  const price = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: import_utils.locales.getText("pisell2.text.price"),
        name: "total",
        rules: [{ required: true }],
        extra: useTotal !== ((_b2 = (_a2 = state.service.cacheItem) == null ? void 0 : _a2._extend) == null ? void 0 : _b2.origin_total) && import_utils.locales.getText("page.booking.text.price-extra")(
          (0, import_utils.formatAmount)(
            (_d2 = (_c2 = state.service.cacheItem) == null ? void 0 : _c2._extend) == null ? void 0 : _d2.origin_total,
            2,
            state.amountSymbol
          ),
          (0, import_utils.formatAmount)(useTotal, 2, state.amountSymbol)
        )
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_priceKeyboard.DiscountKeyboard.InputNumber,
        {
          style: { width: "100%" },
          min: 0,
          precision: 2,
          prefix: state.amountSymbol,
          onChange: handleTotalChange,
          disabled: state.channelDisabledEdit,
          originalValue: ((_f2 = (_e2 = state.service.cacheItem) == null ? void 0 : _e2._extend) == null ? void 0 : _f2.origin_total) || 0,
          placeholder: ((_h2 = (_g2 = state.service.cacheItem) == null ? void 0 : _g2._extend) == null ? void 0 : _h2.origin_total) || "0",
          size: "large",
          keyboardProps: {
            containerProps: {
              renderType: "modal"
            },
            selectType: "dark"
          }
        }
      )
    ));
  }, [
    useTotal,
    (_u = (_t = state.service.cacheItem) == null ? void 0 : _t._extend) == null ? void 0 : _u.origin_total,
    state.amountSymbol,
    state.channelDisabledEdit
  ]);
  const reason = (0, import_react.useMemo)(() => {
    return isReason ? /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: import_utils.locales.getText("pisell2.text.discount-reason"),
        name: "discount_reason"
      },
      /* @__PURE__ */ import_react.default.createElement(import_antd.Input.TextArea, { size: "large" })
    )) : null;
  }, [isReason]);
  const startTime = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2, _d2;
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 12 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: import_utils.locales.getText("pisell2.text.start_time"),
        name: "start_time",
        rules: [{ required: true }]
      },
      SelectTime ? /* @__PURE__ */ import_react.default.createElement(
        SelectTime,
        {
          slice: (_d2 = (_c2 = (_b2 = (_a2 = state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c2.service_time) == null ? void 0 : _d2.value,
          timePickerProps: {
            style: { width: "100%" }
          },
          timeProps: {
            style: { zoom: 0.8 }
          }
        }
      ) : null
    ));
  }, [SelectTime, (_y = (_x = (_w = (_v = state.bookingConfig) == null ? void 0 : _v.config) == null ? void 0 : _w.basic) == null ? void 0 : _x.service_time) == null ? void 0 : _y.value]);
  const duration = (0, import_react.useMemo)(() => {
    console.log("render form duration");
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 12 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: import_utils.locales.getText("pisell2.text.duration"),
        name: "duration",
        rules: [{ required: true }]
      },
      /* @__PURE__ */ import_react.default.createElement(import_duration.default, { ...durationProps, timeObj })
    ));
  }, [durationProps, timeObj]);
  const resource = (0, import_react.useMemo)(() => {
    console.log("render form resource");
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { noStyle: true, name: "resource" }, /* @__PURE__ */ import_react.default.createElement(
      import_Resources.default,
      {
        ref: resourcesRef,
        state,
        cacheItem: state.service.cacheItem,
        getCurrentCacheItem
      }
    ));
  }, [
    state.renderType,
    (_A = (_z = state.service.cacheItem) == null ? void 0 : _z._data) == null ? void 0 : _A.resources,
    (_C = (_B = state.service.cacheItem) == null ? void 0 : _B._data) == null ? void 0 : _C.resourceMaps
  ]);
  const capacity = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { noStyle: true, name: "capacity" }, /* @__PURE__ */ import_react.default.createElement(import_Capacity.default, { state, cacheItem: state.service.cacheItem }));
  }, [
    state.locale,
    state.isTerminal,
    (_F = (_E = (_D = state.service) == null ? void 0 : _D.cacheItem) == null ? void 0 : _E._data) == null ? void 0 : _F.capacitys
  ]);
  const hiddenQuantity = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { hidden: true, name: "quantity" }, /* @__PURE__ */ import_react.default.createElement(import_antd.InputNumber, null));
  }, []);
  const quantity = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { span: 24 }, /* @__PURE__ */ import_react.default.createElement(
      import_antd.Form.Item,
      {
        label: import_utils.locales.getText("pisell2.text.quantity"),
        name: "quantity",
        rules: [{ required: true }]
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.InputNumber,
        {
          size: "large",
          style: { width: "100%" },
          min: 1,
          max: 999999,
          formatter: (value) => {
            if (value !== void 0) {
              return Math.floor(value);
            }
            return value;
          }
        }
      )
    ));
  }, []);
  const footer = (0, import_react.useMemo)(() => {
    var _a2;
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-lowcode__booking-service-body-edit-footer",
        style: (state == null ? void 0 : state.isBookingTicket2) ? { justifyContent: "space-between" } : {}
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-body-edit-footer-left" }, /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "pisell-lowcode__booking-service-delete-wrap",
          onClick: handleDeleteProduct
        },
        /* @__PURE__ */ import_react.default.createElement(import_Delete_wght300_24px.default, { className: "pisell-lowcode__booking-service-delete-icon" })
      ), (state == null ? void 0 : state.isBookingTicket2) && /* @__PURE__ */ import_react.default.createElement(
        import_materials.ConfigProvider,
        {
          theme: {
            token: {
              colorPrimary: "#0d7fa9"
            }
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          import_antd.Button,
          {
            className: "pisell-lowcode__booking-service-buttons-item note-button",
            type: "primary",
            size: "large",
            onClick: () => setNoteModalOpen(true),
            style: { height: "48px", width: "140px" }
          },
          import_utils.locales.getText("pisell2.ticket-booking.note"),
          useNote && /* @__PURE__ */ import_react.default.createElement("span", { className: "note-indicator" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Iconfont, { type: "pisell2-info-circle2" }))
        )
      )),
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Button,
        {
          type: "primary",
          className: "pisell-lowcode__booking-service-body-edit-footer-apple",
          disabled: !isNormalProduct && !((_a2 = state.service.resourcesOrigin) == null ? void 0 : _a2.length),
          onClick: () => {
            form.submit();
          }
        },
        import_utils.locales.getText("pisell2.text.apply")
      )
    );
  }, [(_G = state.service.resourcesOrigin) == null ? void 0 : _G.length, isNormalProduct]);
  console.log("render edit");
  console.log(
    state.service.editModal && !((_H = state.service.cacheItem) == null ? void 0 : _H.autoClose),
    performance.now() - window.pp1,
    "打开商品1"
  );
  const [val, setVal] = (0, import_react.useState)(false);
  (0, import_react.useEffect)(() => {
    if (isShowTimeAndResource) {
      setTimeout(() => {
        setVal(true);
      }, 200);
    } else {
      setVal(false);
    }
  }, [isShowTimeAndResource]);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_drawer.default,
    {
      titleNoWrap: true,
      zIndex: state.service.changeService ? 999 : 1e3,
      forceRender: true,
      mask: state.drawerMask,
      open: !isNoSpecAndPackage && state.service.editModal && !((_I = state.service.cacheItem) == null ? void 0 : _I.autoClose),
      title: import_utils.locales.getText("pisell2.text.edit-service"),
      onClose: () => {
        var _a2;
        (_a2 = window.closeBookingEditModal) == null ? void 0 : _a2.call(window);
        dispatch({
          type: "setService",
          payload: {
            editModal: false,
            cacheItem: null,
            changeService: false
          }
        });
      }
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-body-edit" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { layout: "vertical", form, onFinish }, /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { style: { width: "100%" }, gutter: [16, 0] }, productName, price, reason, val && isShowTimeAndResource && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, startTime, duration, resource, capacity, hiddenQuantity), isNormalProduct && quantity), /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { noStyle: true, name: "note" }, noteModalOpen && /* @__PURE__ */ import_react.default.createElement(
      import_noteModal.default,
      {
        open: noteModalOpen,
        value: form.getFieldValue("note"),
        onConfirm: handleNoteConfirm,
        onDelete: handleNoteDelete,
        onCancel: handleNoteCancel
      }
    ))), footer)
  ));
};
var editService_default = (0, import_react.forwardRef)(Info);
