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/info/service/Lists.tsx
var Lists_exports = {};
__export(Lists_exports, {
  default: () => Lists_default
});
module.exports = __toCommonJS(Lists_exports);
var import_react = __toESM(require("react"));
var import_shoppingCart = __toESM(require("../../../shoppingCart"));
var import_Provider = require("../../../shoppingCart/Provider");
var import_model = require("../model");
var import_utils = require("../service2/utils");
var import_useHolderConfig = __toESM(require("../hooks/useHolderConfig"));
var import_ahooks = require("ahooks");
var import_utils2 = require("../../info2/service/addService/utils");
var import_useAddHolder = __toESM(require("../hooks/useAddHolder"));
var Lists = ({ onEdit, onChange, onAction, isParallelResource }) => {
  var _a;
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
  const { isShowChangeHolder } = (0, import_useHolderConfig.default)(state);
  const { handleAddHolder } = (0, import_useAddHolder.default)(state, dispatch);
  const handleChange = (0, import_ahooks.useMemoizedFn)(
    (currentItem, type, other) => {
      if (state.disabledEdit || state.disableEventBookingEdit) {
        return;
      }
      let products = (0, import_utils.updateServices)(state, currentItem, type, other, {
        handleAddHolder
      });
      if (type === "view" || type === "edit_product") {
        let product = currentItem._origin;
        let cacheItem = { ...product, new: 0 };
        if (isParallelResource) {
          cacheItem = (0, import_utils2.getProductExtend)({
            cacheItem,
            state
          });
        }
        onChange({ editModal: true, cacheItem });
        return onEdit == null ? void 0 : onEdit({ ...product, new: 0 }, type);
      }
      const params = {
        editModal: false,
        value: products,
        edit: true,
        cacheItem: null
      };
      onChange(params);
    }
  );
  const productParams = (0, import_react.useMemo)(() => {
    return {
      hideAddBtn: state.isTerminalDayBookingPage || state.isBookingCreatePage,
      isShowNote: (0, import_utils.isEventBooking)(state),
      isShowPackageNote: false,
      accounts: [],
      isEdit: !!(state == null ? void 0 : state.bookingId),
      disabledEdit: state == null ? void 0 : state.disabledEdit,
      maxLength: (0, import_utils.isEventBooking)(state) ? 1 : 999,
      isShowChangeHolder,
      isShowChangeResource: true,
      isShowAddHolderButton: true,
      isShowEditProduct: !state.isBookingCreatePage
    };
  }, [
    state == null ? void 0 : state.bookingId,
    state == null ? void 0 : state.disabledEdit,
    isShowChangeHolder,
    state.isBookingCreatePage
  ]);
  return /* @__PURE__ */ import_react.default.createElement(import_Provider.CartContext.Provider, { value: { state } }, /* @__PURE__ */ import_react.default.createElement(
    import_shoppingCart.default,
    {
      isParallelResource,
      onAction,
      onChange: handleChange,
      isOpenGroup: false,
      isHideClearCart: true,
      onAddProduct: () => onChange({ addModal: true }),
      productParams: {
        ...productParams,
        products: (0, import_utils.formatProducts)(
          ((_a = state == null ? void 0 : state.service) == null ? void 0 : _a.value) || [],
          state,
          false,
          true,
          isParallelResource
        )
      }
    }
  ));
};
var Lists_default = Lists;
