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/appointmentBooking/hooks.ts
var hooks_exports = {};
__export(hooks_exports, {
  contextUtils: () => contextUtils,
  useAppointmentBooking: () => useAppointmentBooking,
  useAppointmentBookingAccount: () => useAppointmentBookingAccount,
  useAppointmentBookingCart: () => useAppointmentBookingCart,
  useAppointmentBookingLogin: () => useAppointmentBookingLogin,
  useAppointmentBookingProduct: () => useAppointmentBookingProduct,
  useAppointmentBookingResource: () => useAppointmentBookingResource,
  useAppointmentBookingSetting: () => useAppointmentBookingSetting,
  useAppointmentBookingStep: () => useAppointmentBookingStep,
  useIsSkipResourceStep: () => useIsSkipResourceStep,
  useShopDiscount: () => useShopDiscount
});
module.exports = __toCommonJS(hooks_exports);
var import_react = require("react");
var import_utils = require("@pisell/utils");
var import_useEngineContext = require("../../hooks/useEngineContext");
var import_useEngineContext2 = __toESM(require("../../hooks/useEngineContext"));
var import_utils2 = require("./utils");
var import_context = require("./context");
var import_utils3 = require("./components/Resource/utils");
var import_utils4 = require("./utils");
var useAppointmentBooking = () => {
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
  return pisellOS.getModule("appointmentBooking");
};
var useShopDiscount = () => {
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
  return pisellOS.getModule("shopDiscount");
};
var contextUtils = () => {
  var _a;
  const context = (0, import_useEngineContext2.default)();
  const utils = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
  return utils;
};
var useAppointmentBookingStep = () => {
  var _a, _b, _c;
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
  const {
    appointmentBooking,
    setCurrentStep,
    carts,
    openPolicy,
    setLoading,
    setCurrentSelectedResources,
    currentStepParams,
    setIsErrorHolder
  } = (0, import_context.useAppointmentBookingContext)();
  const { isRetailTemplate } = useAppointmentBookingSetting();
  const stepList = ((_c = (_b = (_a = appointmentBooking == null ? void 0 : appointmentBooking.store) == null ? void 0 : _a.step) == null ? void 0 : _b.store) == null ? void 0 : _c.stepList) || [];
  const { isLogin, openLoginModal } = useAppointmentBookingLogin();
  const { isFormSubject } = useAppointmentBookingSetting();
  const { getHolders, checkAccount } = useAppointmentBookingAccount();
  const utils = contextUtils();
  const getCurrentAndLastStep = () => {
    const currentStep = appointmentBooking == null ? void 0 : appointmentBooking.getCurrentStep();
    setCurrentStep(currentStep);
  };
  (0, import_react.useEffect)(() => {
    getCurrentAndLastStep();
    pisellOS.effects.on("appointmentBooking_step:changed", async (res) => {
      if (res.path === "currentStep") {
        getCurrentAndLastStep();
      }
    });
  }, []);
  const getStepIndex = (type, skipNumber = 0) => {
    const currentStep = appointmentBooking == null ? void 0 : appointmentBooking.getCurrentStep();
    const index = (currentStep == null ? void 0 : currentStep.index) || 1;
    if (type === "next") {
      const nextIndex = index + skipNumber;
      return nextIndex + 1 > stepList.length ? stepList.length - 1 : nextIndex;
    }
    if (type === "prev") {
      const prevIndex = index - skipNumber;
      return prevIndex < 0 ? 0 : prevIndex;
    }
  };
  const removeStep = (key) => {
    return appointmentBooking.removeStep(key);
  };
  const addStep = (props, stepKey) => {
    const { index, key, description } = props;
    return appointmentBooking.addStep(
      {
        index,
        key,
        description
      },
      stepKey
    );
  };
  const updateStep = (key, step) => {
    appointmentBooking.updateStep(key, {
      index: step == null ? void 0 : step.index,
      key,
      isSkip: (step == null ? void 0 : step.isSkip) || false
    });
  };
  const nextStep = (isLog = false) => {
    var _a2, _b2, _c2, _d, _e, _f, _g;
    let stepList2 = appointmentBooking.getStepList() || [];
    const currentKey = currentStepParams == null ? void 0 : currentStepParams.key;
    const currentSelectedResources = appointmentBooking.getOtherData(
      "current_selected_resources"
    );
    if (isLog) {
      (0, import_utils4.nextStepLog)(utils, "开始执行下一步方法", [
        { key: "步骤列表", value: JSON.stringify(stepList2) },
        { key: "当前步骤参数", value: JSON.stringify(currentStepParams) }
      ]);
    }
    if (!isRetailTemplate && currentKey === "select-service") {
      const { bookingProcess } = ((_a2 = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a2.productModuleParams) || {};
      const isDateSelectedFirst = bookingProcess === "date_first";
      const hasResourceStep = stepList2 == null ? void 0 : stepList2.find(
        (item) => (item == null ? void 0 : item.key) === "select-resource"
      );
      const hasSelectGuestStep = (_b2 = stepList2 == null ? void 0 : stepList2.find(
        (item) => (item == null ? void 0 : item.key) === "select-guest"
      )) == null ? void 0 : _b2.key;
      const isAllNormalProduct = appointmentBooking == null ? void 0 : appointmentBooking.isCartAllNormalProducts();
      if (isAllNormalProduct) {
        removeStep("select-resource");
        removeStep("select-time");
        removeStep("fill-form");
        if (!isDateSelectedFirst) {
          removeStep("select-date");
        }
      } else if (!hasResourceStep) {
        let targetKey = hasSelectGuestStep ? hasSelectGuestStep : "select-service";
        const isHasDurationProduct = appointmentBooking == null ? void 0 : appointmentBooking.isCartHasDurationProduct();
        if (isHasDurationProduct) {
          if (!isDateSelectedFirst) {
            appointmentBooking.addStep(
              {
                key: "select-date",
                description: import_utils.locales.getText("pisell2.appointment.select.date")
              },
              targetKey
            );
            targetKey = "select-date";
          }
          appointmentBooking.addStep(
            {
              key: "select-resource",
              description: import_utils.locales.getText(
                "pisell2.appointment.select.resource"
              )
            },
            targetKey
          );
          targetKey = "select-resource";
          appointmentBooking.addStep(
            {
              key: "select-time",
              description: import_utils.locales.getText("pisell2.appointment.select.time")
            },
            targetKey
          );
        } else {
          appointmentBooking.addStep(
            {
              key: "select-resource",
              description: import_utils.locales.getText(
                "pisell2.appointment.select.resource"
              )
            },
            targetKey
          );
        }
      }
      stepList2 = (appointmentBooking == null ? void 0 : appointmentBooking.getStepList()) || [];
    }
    let nextStep2 = stepList2[(currentStepParams == null ? void 0 : currentStepParams.index) + 1];
    if (!isRetailTemplate && (nextStep2 == null ? void 0 : nextStep2.key) === "select-resource") {
      const result = appointmentBooking.checkResourceListForDate();
      if (!result) {
        return (0, import_utils2.Toast)(import_utils.locales.getText("pisell2.appointment.unuse.date"));
      }
      const capacityResult = appointmentBooking.checkMaxDurationCapacity();
      if (!capacityResult.success) {
        const getMessage = import_utils.locales.getText(
          "pisell2.appointment.unuse.capacity"
        );
        const message = typeof getMessage === "function" ? getMessage(capacityResult.minAvailableCount) : getMessage;
        return (0, import_utils2.Toast)(message);
      }
    }
    if (!isRetailTemplate && (currentKey == null ? void 0 : currentKey.startsWith("select-resource"))) {
      const { hasError, updatedCartList } = (0, import_utils2.checkAndMarkCartRenderError)(
        currentSelectedResources,
        appointmentBooking,
        utils
      );
      if (hasError) {
        setCurrentSelectedResources(updatedCartList);
        (0, import_utils3.scrollToFirstErrorCard)();
        return;
      }
      let preKey = "";
      currentSelectedResources == null ? void 0 : currentSelectedResources.forEach((cart) => {
        var _a3, _b3;
        const selectedResource2 = cart == null ? void 0 : cart.currentSelectedResource;
        const resourceItem = (selectedResource2 == null ? void 0 : selectedResource2.resourceItem) || {};
        const formId = (_a3 = selectedResource2 == null ? void 0 : selectedResource2.renderItem) == null ? void 0 : _a3.resource_form_id;
        const policyId = (_b3 = selectedResource2 == null ? void 0 : selectedResource2.renderItem) == null ? void 0 : _b3.policy_id;
        const formKey = `fill-form_@${resourceItem == null ? void 0 : resourceItem.form_id}-${resourceItem == null ? void 0 : resourceItem.code}-${cart == null ? void 0 : cart._id}-${formId}-${policyId}`;
        if (formId) {
          const description = import_utils.locales.getText("pisell2.appointment.fill-form");
          const beforeKey = (0, import_utils2.getFormInsertBeforeKey)(currentKey, stepList2);
          appointmentBooking.addStep(
            { key: formKey, description },
            preKey || beforeKey
          );
          preKey = formKey;
        } else {
          appointmentBooking.removeStep(formKey);
        }
      });
      stepList2 = appointmentBooking.getStepList();
      const selectedResource = (_c2 = currentSelectedResources == null ? void 0 : currentSelectedResources[0]) == null ? void 0 : _c2.currentSelectedResource;
      if (selectedResource) {
        const originRenderLists = ((_d = selectedResource == null ? void 0 : selectedResource.resourceItem) == null ? void 0 : _d.originRenderLists) || [];
        const currentResourceIndex = originRenderLists == null ? void 0 : originRenderLists.findIndex(
          (item) => {
            var _a3;
            return item.id === ((_a3 = selectedResource == null ? void 0 : selectedResource.renderItem) == null ? void 0 : _a3.form_id);
          }
        );
        const nextResource = originRenderLists == null ? void 0 : originRenderLists[currentResourceIndex + 1];
        const resourceKey = `select-resource_@${nextResource == null ? void 0 : nextResource.form_id}-${nextResource == null ? void 0 : nextResource.code}`;
        if (nextResource) {
          const beforeKey = (_e = stepList2[stepList2.length - 2]) == null ? void 0 : _e.key;
          appointmentBooking.addStep(
            { key: resourceKey, description: "" },
            beforeKey
          );
        } else {
          appointmentBooking.removeStep(resourceKey);
        }
      }
    }
    stepList2 = appointmentBooking.getStepList();
    nextStep2 = stepList2[(currentStepParams == null ? void 0 : currentStepParams.index) + 1];
    if (((_f = nextStep2 == null ? void 0 : nextStep2.key) == null ? void 0 : _f.startsWith("select-resource_")) || (nextStep2 == null ? void 0 : nextStep2.key) === "confirm-information") {
      const selectedResource = ((_g = currentSelectedResources == null ? void 0 : currentSelectedResources[0]) == null ? void 0 : _g.currentSelectedResource) || {};
      const renderItem = (selectedResource == null ? void 0 : selectedResource.renderItem) || {};
      if (isLog) {
        (0, import_utils4.nextStepLog)(utils, "开始检测是否登录和打开协议弹窗", [
          { key: "下一步步骤", value: JSON.stringify(nextStep2) },
          { key: "渲染项", value: JSON.stringify(renderItem) }
        ]);
      }
      const logNextStepAsyncError = (error) => {
        const msg = (error == null ? void 0 : error.message) || "未知错误";
        (0, import_utils4.nextStepLog)(utils, "登录检测登录异常", [
          { key: "错误信息", value: msg }
        ]);
      };
      const checkHolder = async (isLoginTrigger = false) => {
        try {
          setLoading(false);
          if (isRetailTemplate || (appointmentBooking == null ? void 0 : appointmentBooking.isCartAllNormalProducts())) {
            return appointmentBooking.next();
          }
          let cartLists = carts || [];
          if (!(carts == null ? void 0 : carts.length)) {
            const newCarts = await appointmentBooking.getCart();
            cartLists = newCarts || [];
          } else {
            cartLists = carts || [];
          }
          const appoimentCarts = cartLists.filter(
            (n) => !(appointmentBooking == null ? void 0 : appointmentBooking.isTargetCartIdNormalProduct(n._id))
          );
          const { hasError, isEnableSkuHolderRule } = (0, import_utils2.checkAndGoNext)(
            isFormSubject,
            checkAccount,
            appoimentCarts
          );
          setIsErrorHolder(hasError);
          if (isLog) {
            (0, import_utils4.nextStepLog)(utils, "开始检测holder数据", [
              { key: "是否有错误", value: hasError },
              { key: "协议id", value: renderItem == null ? void 0 : renderItem.policy_id }
            ]);
          }
          if (hasError) {
            (0, import_utils3.scrollToFirstErrorCard)(".pisell-lowcode-product-card-select-holder-error");
            return;
          }
          if (isLoginTrigger && isEnableSkuHolderRule) {
            return;
          }
          if (!!(renderItem == null ? void 0 : renderItem.policy_id)) {
            openPolicy({ id: renderItem == null ? void 0 : renderItem.policy_id }, () => {
              return appointmentBooking.next();
            });
          } else {
            return appointmentBooking.next();
          }
        } catch (error) {
          setLoading(false);
          logNextStepAsyncError(error);
        }
      };
      const checkLogin = async () => {
        try {
          if (isLog) {
            (0, import_utils4.nextStepLog)(utils, "开始检测是否登录", [
              { key: "是否登录", value: isLogin }
            ]);
          }
          if (!isLogin) {
            const { pubsub } = utils;
            if (isLog) {
              (0, import_utils4.nextStepLog)(utils, "进入打开登录弹窗");
            }
            pubsub.once("pisell1.login.success", (res) => {
              if (isLog) {
                (0, import_utils4.nextStepLog)(utils, "登录弹窗回调", [
                  { key: "登录状态", value: res }
                ]);
              }
              if (res === "success") {
                if (isFormSubject && !isRetailTemplate && !(appointmentBooking == null ? void 0 : appointmentBooking.isCartAllNormalProducts())) {
                  const customer = (0, import_utils2.getCustomer)(utils);
                  appointmentBooking == null ? void 0 : appointmentBooking.refreshAllHolderFormRecords({
                    customer_id: customer == null ? void 0 : customer.id
                  });
                }
                checkHolder(true);
              }
              if (res === "close") {
                setLoading(false);
              }
            });
            return openLoginModal({
              callback: (status) => {
              }
            });
          } else {
            return checkHolder();
          }
        } catch (error) {
          setLoading(false);
          logNextStepAsyncError(error);
        }
      };
      if ((nextStep2 == null ? void 0 : nextStep2.key) !== "confirm-information") {
        if (!(renderItem == null ? void 0 : renderItem.policy_id)) {
          return appointmentBooking.next();
        }
        return openPolicy({ id: renderItem == null ? void 0 : renderItem.policy_id }, () => {
          const cartItem = carts == null ? void 0 : carts[0];
          appointmentBooking.updateCart({
            _id: cartItem == null ? void 0 : cartItem._id,
            ...cartItem
          });
          appointmentBooking.next();
        });
      } else {
        return checkLogin();
      }
    }
    appointmentBooking.next();
  };
  return { getStepIndex, stepList, removeStep, addStep, updateStep, nextStep };
};
var useAppointmentBookingProduct = () => {
  const { appointmentBooking } = (0, import_context.useAppointmentBookingContext)();
  const { productModuleParams } = (appointmentBooking == null ? void 0 : appointmentBooking.otherParams) || {};
  const { bookingProcess } = productModuleParams || {};
  const getProducts = async () => {
    var _a;
    if (bookingProcess === "date_first") {
      const dates = await appointmentBooking.getDateRange();
      if (!dates || !dates.length) return;
      const { productModuleParams: productModuleParams3 } = (appointmentBooking == null ? void 0 : appointmentBooking.otherParams) || {};
      const productList2 = await appointmentBooking.loadProductByScheduleDate({
        date: (_a = dates[0]) == null ? void 0 : _a.date,
        ...productModuleParams3
      });
      return productList2;
    }
    const { productModuleParams: productModuleParams2 } = (appointmentBooking == null ? void 0 : appointmentBooking.otherParams) || {};
    const productList = await appointmentBooking.loadProducts(
      productModuleParams2
    );
    return productList;
  };
  const checkProductType = async (productId) => {
    const result = await appointmentBooking.getProductTypeById(productId);
    return result;
  };
  return { checkProductType, getProducts };
};
var useAppointmentBookingCart = () => {
  var _a;
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
  const utils = contextUtils();
  const { appointmentBooking, setCarts, setSummary, setIsAgreeDepositPolicy } = (0, import_context.useAppointmentBookingContext)();
  const { bookingSubject } = ((_a = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a.productModuleParams) || {};
  const getCartAndSummary = async () => {
    var _a2;
    const locale = ((_a2 = utils == null ? void 0 : utils.storage) == null ? void 0 : _a2.get("umi_locale")) || "en-US";
    const symbol = (utils == null ? void 0 : utils.getSymbolic()) || "$";
    const carts = await appointmentBooking.getCart();
    const accountLists = await appointmentBooking.getAccounts();
    const newCarts = carts == null ? void 0 : carts.map((item) => {
      var _a3;
      return {
        ...item,
        // addHolderButtonText: utils?.translation(formMap?.[formId]?.form?.form?.setting?.title),
        format: ["HH:mm", "HH:mm"],
        show_time: true,
        duration_type: ((_a3 = item == null ? void 0 : item.duration) == null ? void 0 : _a3.type) || "minutes",
        locale,
        symbol,
        // holders: formatHolder(accountLists),
        allowClearHolder: true,
        allowClearResource: true,
        isMultipleResource: true
      };
    });
    setCarts(newCarts || []);
    const summary = await appointmentBooking.getSummary();
    setSummary(summary || {});
    if (!carts.length) {
      setIsAgreeDepositPolicy(false);
    }
  };
  (0, import_react.useEffect)(() => {
    getCartAndSummary();
    pisellOS.effects.on("appointmentBooking_cart:changed", async () => {
      getCartAndSummary();
    });
  }, []);
};
var useAppointmentBookingLogin = () => {
  var _a, _b;
  const utils = contextUtils();
  const isLogin = !!((_b = (_a = utils == null ? void 0 : utils.token) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a));
  const openLoginModal = (params) => {
    const { callback, data = {} } = params || {};
    utils.action({
      type: "pisell1.login",
      data: {
        ...data
        // type: 'plugin'
      },
      callback
    });
  };
  return { isLogin, openLoginModal };
};
var useAppointmentBookingAccount = () => {
  var _a;
  const utils = contextUtils();
  const pisellOS = (0, import_useEngineContext.usePisellOS)();
  const appointmentBooking = useAppointmentBooking();
  const [accountLists, setAccountLists] = (0, import_react.useState)([]);
  const { bookingSubject } = ((_a = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a.productModuleParams) || {};
  const form_id = bookingSubject == null ? void 0 : bookingSubject.form_id;
  const getAccountLists = async () => {
    const data = await appointmentBooking.getAccounts();
    setAccountLists(data || []);
  };
  (0, import_react.useEffect)(() => {
    getAccountLists();
    pisellOS.effects.on(
      "appointmentBooking_accountList:changed",
      async (res) => {
        if (res.path === "accounts") {
          getAccountLists();
        }
      }
    );
  }, []);
  const getHolders = async () => {
    var _a2, _b, _c;
    const shop_id = (_c = (_b = (_a2 = utils.getStore().getState()) == null ? void 0 : _a2.global) == null ? void 0 : _b.shop) == null ? void 0 : _c.id;
    const customer = (0, import_utils2.getCustomer)(utils);
    if (!shop_id || !form_id || !(customer == null ? void 0 : customer.id)) return [];
    const params = {
      url: "/form/data/v1",
      query: {
        customer_id: customer == null ? void 0 : customer.id,
        form_id,
        shop_id
      }
    };
    const data = await appointmentBooking.fetchHolderAccountsAsync(params);
    const newData = data == null ? void 0 : data.map((item) => {
      return {
        id: item == null ? void 0 : item.form_record_id,
        label: item == null ? void 0 : item.main_field
      };
    });
    return newData || [];
  };
  const addAccount = async (val, type) => {
    const customer = (0, import_utils2.getCustomer)(utils);
    const result = await appointmentBooking.addAccount(val, {
      type,
      customerId: customer == null ? void 0 : customer.id
    });
    return result;
  };
  const checkAccount = (type) => {
    return appointmentBooking.checkBeforeSubmitOrder(type);
  };
  return { accountLists, getHolders, form_id, addAccount, checkAccount };
};
var useAppointmentBookingResource = () => {
  const { appointmentBooking, setResources, setTimes } = (0, import_context.useAppointmentBookingContext)();
  const { resourceSort } = (appointmentBooking == null ? void 0 : appointmentBooking.otherParams) || {};
  const getResourceList = () => {
    let resources = appointmentBooking.getResourcesList();
    const { resources: processedResources, resourceCodes } = (0, import_utils2.processResourceList)(
      resources,
      resourceSort
    );
    setResources(processedResources || []);
    return { resources: processedResources, resourceCodes };
  };
  const getResourceTimeSlot = async (index) => {
    var _a, _b;
    const { resourceCodes } = getResourceList();
    let split = 10;
    const { basic } = ((_a = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a.appointmentBoard) || {};
    const serviceTime = (_b = basic == null ? void 0 : basic.service_time) == null ? void 0 : _b.value;
    if (serviceTime) {
      split = serviceTime;
    }
    const code = resourceCodes == null ? void 0 : resourceCodes[index || 0];
    const data = await appointmentBooking.getTimeSlotByAllResources(code, split);
    setTimes(data || []);
  };
  return { getResourceTimeSlot, getResourceList };
};
var useIsSkipResourceStep = () => {
  const { currentStepParams } = (0, import_context.useAppointmentBookingContext)();
  const { getResourceList } = useAppointmentBookingResource();
  const { isFormSubject } = useAppointmentBookingSetting();
  const appointmentBooking = useAppointmentBooking();
  const { nextStep } = useAppointmentBookingStep();
  const checkSkipResourceStep = async () => {
    try {
      const { resources } = getResourceList();
      const accountLists = await appointmentBooking.getAccounts();
      const { isSystem, isSkip, form_code } = (0, import_utils2.currentAppointmentBoard)(
        currentStepParams.key,
        resources,
        appointmentBooking
      );
      if (isSystem) {
        nextStep();
        return true;
      }
      if ((accountLists == null ? void 0 : accountLists.length) === 1 || isFormSubject) {
        const renderLists = (0, import_utils2.currentRenderLists)(resources, form_code);
        let _isSkip = false;
        if ((renderLists == null ? void 0 : renderLists.length) === 1) {
          _isSkip = isSkip || false;
        } else {
          _isSkip = false;
        }
        if (_isSkip) {
          nextStep();
          return true;
        }
        return _isSkip;
      } else {
        return false;
      }
    } catch (error) {
      return false;
    }
  };
  return { checkSkipResourceStep };
};
var useAppointmentBookingSetting = () => {
  var _a, _b, _c;
  const utils = contextUtils();
  const { appointmentBooking } = (0, import_context.useAppointmentBookingContext)();
  const { bookingProcess, bookingSubject, customPageId, channel } = ((_a = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a.productModuleParams) || {};
  const setOtherData = (key, val) => {
    return appointmentBooking.setOtherData(key, val);
  };
  const getOtherData = (key) => {
    return appointmentBooking.getOtherData(key);
  };
  const formName = (0, import_react.useMemo)(() => {
    return utils == null ? void 0 : utils.translation(bookingSubject == null ? void 0 : bookingSubject.form_name);
  }, [bookingSubject]);
  return {
    // 是否先选择日期
    isDateSelectedFirst: bookingProcess === "date_first",
    // 主体是否是表单
    isFormSubject: (bookingSubject == null ? void 0 : bookingSubject.type) === "form",
    // 是否是零售模版
    isRetailTemplate: ((_b = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _b.isRetailTemplate) || false,
    customPageId,
    channel,
    bookingSubject,
    setOtherData,
    getOtherData,
    formName,
    bookingSetting: ((_c = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _c.bookingSetting) || {}
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  contextUtils,
  useAppointmentBooking,
  useAppointmentBookingAccount,
  useAppointmentBookingCart,
  useAppointmentBookingLogin,
  useAppointmentBookingProduct,
  useAppointmentBookingResource,
  useAppointmentBookingSetting,
  useAppointmentBookingStep,
  useIsSkipResourceStep,
  useShopDiscount
});
