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/hooks/useInfoHolder.ts
var useInfoHolder_exports = {};
__export(useInfoHolder_exports, {
  default: () => useInfoHolder_default
});
module.exports = __toCommonJS(useInfoHolder_exports);
var import_ahooks = require("ahooks");
var import_react = require("react");
var import_useHolderConfig = __toESM(require("./useHolderConfig"));
var import_utils = require("../utils");
var import_useGetHolderList = __toESM(require("./useGetHolderList"));
var import_utils2 = require("../../info2/service/addService/utils");
var useInfoHolder = (state, dispatch) => {
  var _a, _b, _c, _d;
  const detailRef = (0, import_react.useRef)();
  const { holder, isFormSubject, appointment_subject } = (0, import_useHolderConfig.default)(state);
  const getHolders = (0, import_useGetHolderList.default)(state, dispatch);
  (0, import_react.useEffect)(() => {
    if (isFormSubject) {
      getHolders();
    }
  }, [appointment_subject, holder, (_b = (_a = state.client) == null ? void 0 : _a.value) == null ? void 0 : _b.id]);
  const appointment_card = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2;
    return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.information_tab) == null ? void 0 : _c2.appointment_card) || {
      quick_time: 1
    };
  }, [(_d = (_c = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _c.config) == null ? void 0 : _d.information_tab]);
  const showAddTimeModal = (0, import_react.useMemo)(() => {
    return (0, import_utils.isOpenAddTime)(state) && !state.isBookingTicket2;
  }, [state, appointment_card.quick_time]);
  const handleEdit = (0, import_ahooks.useMemoizedFn)((cacheItem, type) => {
    var _a2, _b2;
    console.time("handleEdit");
    console.log(performance.now() - window.pp1, "打开商品4");
    (_b2 = (_a2 = detailRef.current) == null ? void 0 : _a2.init) == null ? void 0 : _b2.call(_a2, cacheItem, false, type === "edit_product");
  });
  const dispatchService = (type, payload) => {
    dispatch({
      type,
      payload: { ...payload }
    });
  };
  const handleAction = (0, import_ahooks.useMemoizedFn)((dataSource) => {
    const cacheItem = (0, import_utils2.getProductExtend)({
      cacheItem: { ...dataSource._origin, new: 0 },
      state
    });
    dispatch({
      type: "setService",
      payload: {
        addTimeModal: true,
        cacheItem
      }
    });
  });
  return {
    detailRef,
    handleEdit,
    dispatchService,
    handleAction,
    showAddTimeModal
  };
};
var useInfoHolder_default = useInfoHolder;
