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/ticketBooking/index.tsx
var ticketBooking_exports = {};
__export(ticketBooking_exports, {
  default: () => ticketBooking_default,
  ticketBookingInitialState: () => ticketBookingInitialState
});
module.exports = __toCommonJS(ticketBooking_exports);
var import_react = __toESM(require("react"));
var import_miniRedux = require("./miniRedux");
var import_utils = require("@pisell/utils");
var import_dayjs = __toESM(require("dayjs"));
var import_lodash = require("lodash");
var import_ticketBooking = __toESM(require("./components/ticketBooking/index"));
var import_utils2 = require("../../utils");
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var import_utils3 = require("./utils");
var import_locales = __toESM(require("./locales"));
var import_menuBar = __toESM(require("./components/menuBar"));
var import_ahooks = require("ahooks");
var import_OsKeyContext = require("./context/OsKeyContext");
var import_IsActiveContext = require("./context/IsActiveContext");
var import_index = require("./index.less");
var ticketBookingInitialState = {
  amountSymbol: "$",
  modalState: {
    client: {
      showModal: false,
      clients: [],
      value: {
        id: 0,
        nickname: "Select a customer"
      },
      clientsParams: {
        skip: 1,
        num: 100,
        search: ""
      },
      edit: false
    },
    date: {
      value: (0, import_dayjs.default)(),
      edit: false
    },
    service: {
      addModal: false,
      editModal: false,
      reloadResourceModal: false,
      services: [],
      resources: [],
      value: [],
      cacheItem: null,
      edit: false
    },
    pet: {
      showModal: false,
      pets: [],
      value: {},
      edit: false
    },
    addons: {
      showModal: false,
      value: [],
      productList: [],
      originData: [],
      edit: false,
      load: false
    },
    form: {
      value: {},
      forms: [],
      edit: false
    },
    notes: {
      orderNote: "",
      internalNotes: [],
      edit: false
    },
    // 是否禁用编辑
    disabledEdit: false,
    // 渠道禁止编辑
    channelDisabledEdit: false,
    // 预约状态
    appointment_status: "new",
    eventOtherParams: void 0
  },
  bookingConfig: null,
  /** 平面图等入口传入的餐牌 ID，优先于 board menu_list 用于 getProducts */
  associated_menu_list_ids: void 0,
  bookingDetail: null,
  bookingId: 0,
  loading: false,
  open: false,
  isShowDeposit: false,
  activeKey: "info",
  exitModal: false,
  rebookState: {
    open: false,
    date: "2024-03-13 18:00"
  },
  bookingFunctions: {},
  // Event活动预约抽屉
  eventOpen: false,
  renderType: "booking",
  // 是否是rebook模式
  openRebook: false,
  // 禁用活动预约编辑
  disableEventBookingEdit: false,
  isShowInfo: false,
  // 是否pin住
  persistent: true,
  // persistent:
  //   this.utils.storage.get(`drawer-booking`) === 'true' ??
  //   this.utils.isTerminal(),
  // 是否定时设置当前时间
  intervalSetTime: true,
  // 时间是否更改
  isTimeChange: false,
  // 日期是否更改
  isDateChange: false,
  list: {
    /** 列表loading */
    isLoading: false,
    /** 预约列表数据 */
    bookingList: [],
    /** 预约列表查询参数 */
    params: {
      ["with"]: [
        "order",
        "order.customer",
        "contacts",
        "item",
        "appointmentForm.formRecord",
        "holder.formRecord"
      ],
      /** 创建时间范围 */
      booking_time_start_between: (0, import_utils3.getDefaultStartParam)(),
      child_booking: 1,
      // item_type: this.props?.dynamicParams?.type,
      skip: 1,
      num: 1e3
    },
    showList: [],
    listSelectType: "all",
    search: "",
    sort: ""
  },
  confirmOpen: false,
  createCount: 0,
  verticalAddServiceKey: 0,
  currentProduct: null,
  bookingConfigParams: {
    item_type: "appointment_booking"
  },
  productExtensionType: [
    "appointment_ticket",
    "session_ticket",
    "product_appointment",
    "service_product",
    "session_product",
    "normal",
    "product_appointment"
  ],
  // 是否是平行资源预约的booking
  isParallelResourcesBooking: null,
  // 是否是弹窗编辑模式
  isEditTicketMode: false,
  // 订单已付金额数据
  paymentPaid: {
    value: {
      paidAmount: 0,
      paidAmountWithoutSurcharge: 0
    }
  }
};
var ticketBooking_default = (props) => {
  var _a, _b, _c, _d, _e, _f, _g, _h;
  const {
    productExtensionType,
    bookingConfigParams: propsBookingConfigParams,
    isShowMenuBar = true,
    onPrerenderComplete,
    isShowTimeBar: propsIsShowTimeBar = true,
    isShowFloatButtons: propsIsShowFloatButtons = true,
    productDisplayConfig: propsProductDisplayConfig,
    isActive = true,
    rulesHooks: propsRulesHooks,
    storeRef: externalStoreRef,
    editModeInitialState,
    secondaryScreenDisplay,
    bodyTopSlot
  } = props;
  const [activeNavKey, setActiveNavKey] = (0, import_ahooks.useLocalStorageState)(
    "pisell-ticket-booking-nav-key",
    {
      defaultValue: "ticket"
    }
  );
  const bookingConfigParams = (0, import_react.useMemo)(() => {
    if (isShowMenuBar && activeNavKey === "food") {
      return {
        ...propsBookingConfigParams,
        sub_type: "food",
        source_type: "pos"
      };
    }
    return propsBookingConfigParams;
  }, [isShowMenuBar, activeNavKey, propsBookingConfigParams]);
  const isShowTimeBar = (0, import_react.useMemo)(() => {
    return isShowMenuBar && activeNavKey === "food" ? false : propsIsShowTimeBar;
  }, [isShowMenuBar, activeNavKey, propsIsShowTimeBar]);
  const isShowFloatButtons = (0, import_react.useMemo)(() => {
    return isShowMenuBar && activeNavKey === "food" ? false : propsIsShowFloatButtons;
  }, [isShowMenuBar, activeNavKey, propsIsShowFloatButtons]);
  const osKey = (0, import_react.useMemo)(() => {
    return `${bookingConfigParams == null ? void 0 : bookingConfigParams.sub_type}${(bookingConfigParams == null ? void 0 : bookingConfigParams.osKey) ? `-${bookingConfigParams == null ? void 0 : bookingConfigParams.osKey}` : ""}`;
  }, [bookingConfigParams]);
  const productDisplayConfig = (0, import_react.useMemo)(() => {
    if (isShowMenuBar && activeNavKey === "food") {
      return "sku-list-a5";
    }
    return propsProductDisplayConfig;
  }, [isShowMenuBar, activeNavKey, propsProductDisplayConfig]);
  const internalStoreRef = (0, import_react.useRef)(null);
  const storeRef = externalStoreRef ?? internalStoreRef;
  const context = (0, import_useEngineContext.default)();
  const { pisellos, pisellosAllModule, businessUtils } = (_a = context.appHelper) == null ? void 0 : _a.utils;
  const { BookingTicket, ShopDiscountImpl } = pisellosAllModule || {};
  import_utils.locales.init(
    import_locales.default,
    ((_f = (_e = (_d = (_c = (_b = context.appHelper.utils) == null ? void 0 : _b.getApp) == null ? void 0 : _c.call(_b)) == null ? void 0 : _d.locales) == null ? void 0 : _e.getLocale) == null ? void 0 : _f.call(_e)) || ((_h = (_g = context.appHelper.utils) == null ? void 0 : _g.storage) == null ? void 0 : _h.get("umi_locale")) || "en"
  );
  (0, import_react.useLayoutEffect)(() => {
    import_utils2.request.setRequest(context.appHelper.utils.request);
  }, []);
  (0, import_react.useMemo)(() => {
    const store = (0, import_miniRedux.createStore)({
      ...(0, import_lodash.cloneDeep)(ticketBookingInitialState),
      bookingConfigParams,
      productExtensionType,
      ...editModeInitialState || {}
    });
    storeRef.current = store;
  }, [bookingConfigParams, productExtensionType, editModeInitialState]);
  (0, import_react.useMemo)(() => {
    var _a2;
    const bookingTicketModule = pisellos == null ? void 0 : pisellos.getModule((0, import_utils3.getBookingTicketKey)(osKey));
    if (BookingTicket && !bookingTicketModule) {
      pisellos == null ? void 0 : pisellos.registerModule(new BookingTicket((0, import_utils3.getBookingTicketKey)(osKey)), {
        initialState: {},
        otherParams: {
          cacheId: (0, import_utils3.getBookingTicketKey)(osKey),
          platform: "shop",
          isFranchisee: (_a2 = businessUtils == null ? void 0 : businessUtils.getAppByModal) == null ? void 0 : _a2.call(businessUtils, "franchisee")
        }
      });
    }
    const shopDiscountModule = pisellos == null ? void 0 : pisellos.getModule((0, import_utils3.getShopDiscountKey)(osKey));
    if (ShopDiscountImpl && !shopDiscountModule) {
      pisellos == null ? void 0 : pisellos.registerModule(new ShopDiscountImpl((0, import_utils3.getShopDiscountKey)(osKey)), {
        otherParams: {
          platform: "shop",
          rules: {
            hooks: propsRulesHooks || import_utils3.rulesHooks
          }
        }
      });
    }
  }, [osKey]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-ticket-booking-wrapper" }, isShowMenuBar && /* @__PURE__ */ import_react.default.createElement(import_menuBar.default, { activeNavKey, onNavChange: setActiveNavKey }), /* @__PURE__ */ import_react.default.createElement(import_IsActiveContext.IsActiveProvider, { isActive }, /* @__PURE__ */ import_react.default.createElement(import_OsKeyContext.OsKeyProvider, { osKey, businessCode: props == null ? void 0 : props.businessCode }, /* @__PURE__ */ import_react.default.createElement(import_miniRedux.Provider, { store: storeRef.current, key: activeNavKey }, /* @__PURE__ */ import_react.default.createElement(
    import_ticketBooking.default,
    {
      onPrerenderComplete,
      productDisplayConfig,
      isShowTimeBar,
      isShowFloatButtons,
      secondaryScreenDisplay,
      bodyTopSlot
    }
  )))));
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ticketBookingInitialState
});
