var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/booking/info/service2/hooks/useSelectPet.tsx
var useSelectPet_exports = {};
__export(useSelectPet_exports, {
  default: () => useSelectPet_default
});
module.exports = __toCommonJS(useSelectPet_exports);
var import_react = require("react");
var import_utils = require("../utils");
var useSelectPet = (state) => {
  var _a, _b;
  const isDaysBookingBol = (0, import_react.useMemo)(() => {
    return (0, import_utils.isDayBooking)(state);
  }, [state == null ? void 0 : state.renderType]);
  const petLists = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c, _d, _e, _f;
    const form_id = ((_d = (_c = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c.appointment_subject) == null ? void 0 : _d.form_id) || 0;
    return ((_f = (_e = state == null ? void 0 : state.pet) == null ? void 0 : _e.value) == null ? void 0 : _f[form_id]) || [];
  }, [(_a = state == null ? void 0 : state.pet) == null ? void 0 : _a.value]);
  const holderLists = (0, import_react.useMemo)(() => {
    var _a2;
    if (isDaysBookingBol) {
      const _lists = (0, import_utils.formatHolderLists)(petLists);
      return _lists;
    }
    return ((_a2 = state == null ? void 0 : state.pet) == null ? void 0 : _a2.holders) || [];
  }, [petLists, isDaysBookingBol, (_b = state == null ? void 0 : state.pet) == null ? void 0 : _b.holders]);
  const getHolderName = (id) => {
    if (!holderLists.length) return "";
    const resource = holderLists.find((d) => d.id === id);
    return resource == null ? void 0 : resource.main_field;
  };
  return {
    petLists,
    holderLists,
    getHolderName
  };
};
var useSelectPet_default = useSelectPet;
