import React, { useRef } from 'react';
import classNames from 'classnames';
import SaleDetailBase from "../../../../plus/saleDetail/Base";
import BigSaleBookingFloatingPanel from "../../components/BookingFloatingPanel";
import BigSaleFloatingActions from "../../components/FloatingActions";
import { BigSaleProductList } from "../../components/ProductList";
import BigSaleTimeBar from "../../components/TimeBar";
import { useSyncBigSaleCartToCds } from "../../hooks";
function pickSaleDetailContext(bigSaleContext, onOrderComplete) {
  return {
    sales: bigSaleContext.sales,
    customer: bigSaleContext.customer,
    cart: bigSaleContext.cart,
    summary: bigSaleContext.summary,
    booking: bigSaleContext.booking,
    onOrderComplete: onOrderComplete
  };
}
export function StandardBigSaleTemplate(_ref) {
  var _ref$isActive = _ref.isActive,
    isActive = _ref$isActive === void 0 ? true : _ref$isActive,
    context = _ref.context,
    mode = _ref.mode,
    variant = _ref.variant,
    productLoadParams = _ref.productLoadParams,
    productDisplayConfig = _ref.productDisplayConfig,
    productCatalogSessionKey = _ref.productCatalogSessionKey,
    saleDetailTemplate = _ref.saleDetailTemplate,
    saleDetailModuleConfig = _ref.saleDetailModuleConfig,
    orderId = _ref.orderId,
    locale = _ref.locale,
    saleDetailHeaderSlot = _ref.saleDetailHeaderSlot,
    onOrderComplete = _ref.onOrderComplete;
  var floatingPanelRef = useRef(null);
  var timeBarRef = useRef(null);
  useSyncBigSaleCartToCds(context, {
    enabled: orderId == null
  });
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("section", {
    className: "pisell-big-sale__product-panel"
  }, /*#__PURE__*/React.createElement(BigSaleProductList, {
    isActive: isActive,
    mode: mode,
    context: context,
    productLoadParams: productLoadParams,
    productDisplayConfig: productDisplayConfig,
    productCatalogSessionKey: productCatalogSessionKey,
    variant: variant
  }), /*#__PURE__*/React.createElement(BigSaleFloatingActions, {
    context: context,
    variant: variant,
    floatingPanelRef: floatingPanelRef,
    timeBarRef: timeBarRef
  })), /*#__PURE__*/React.createElement("section", {
    className: classNames('pisell-big-sale__sale-detail', {
      'pisell-big-sale__sale-detail--has-header': Boolean(saleDetailHeaderSlot)
    })
  }, saleDetailHeaderSlot, /*#__PURE__*/React.createElement("div", {
    className: "pisell-big-sale__sale-detail-body"
  }, /*#__PURE__*/React.createElement(SaleDetailBase, {
    context: pickSaleDetailContext(context, onOrderComplete),
    renderType: "current",
    template: saleDetailTemplate,
    variant: variant,
    mobilePresentation: "bottomSheet",
    moduleConfig: saleDetailModuleConfig
  }))), /*#__PURE__*/React.createElement(BigSaleTimeBar, {
    context: context,
    productLoadParams: productLoadParams,
    orderId: orderId,
    locale: locale,
    variant: variant,
    ref: timeBarRef
  }), /*#__PURE__*/React.createElement(BigSaleBookingFloatingPanel, {
    context: context,
    ref: floatingPanelRef,
    variant: variant
  }));
}
export default StandardBigSaleTemplate;