const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_serve = require("../../booking/info/service/serve.js");
const require_utils = require("../../ticketBooking/components/addServiceVariant/utils.js");
const require_utils$1 = require("../utils.js");
const require_utils$2 = require("../../booking/info/service2/utils.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_index = require("../../../pro/compensatedPisellContainer/index.js");
const require_openNormalService = require("../../booking/info2/service/openNormalService.js");
const require_index$1 = require("../../../pro/Selector/index.js");
const require_server = require("../server.js");
const require_useSkuModal = require("./useSkuModal.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let ahooks = require("ahooks");
//#region src/components/shoppingCart/hooks/usePromotionModal.tsx
const FALLBACK_RESPONSIVE_INFO = {
	currentBreakpoint: "desktop",
	deviceType: "desktop"
};
const useFallbackResponsive = () => FALLBACK_RESPONSIVE_INFO;
const usePromotionModal = (options) => {
	var _context$appHelper, _context$appHelper$ge, _responsive$hooks;
	const context = require_useEngineContext.default();
	const app = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getApp) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper);
	const responsive = app === null || app === void 0 ? void 0 : app.responsive;
	const responsiveInfo = (typeof (responsive === null || responsive === void 0 || (_responsive$hooks = responsive.hooks) === null || _responsive$hooks === void 0 ? void 0 : _responsive$hooks.useResponsive) === "function" ? responsive.hooks.useResponsive : useFallbackResponsive)() || FALLBACK_RESPONSIVE_INFO;
	const currentVariant = responsiveInfo.currentBreakpoint || responsiveInfo.deviceType || "desktop";
	const [open, setOpen] = (0, react.useState)(false);
	const [selected, setSelected] = (0, react.useState)("");
	const [loading, setLoading] = (0, react.useState)(false);
	const [products, setProducts] = (0, react.useState)([]);
	const [currentItem, setCurrentItem] = (0, react.useState)({});
	const productsRef = (0, react.useRef)(null);
	const [cartProducts, setCartProducts] = (0, react.useState)([]);
	const [randomKey, setRandomKey] = (0, react.useState)(Math.random());
	(0, react.useEffect)(() => {
		const _products = require_utils$1.formatProductDatas(products, currentItem, selected);
		productsRef.current = _products || [];
		if ((_products === null || _products === void 0 ? void 0 : _products.length) && Array.isArray(_products) && currentItem) setCartProducts(require_utils$1.formatCartProducts({
			products: _products,
			currentItem
		}));
		else setCartProducts([]);
	}, [
		products,
		currentItem,
		selected
	]);
	/**
	* @description: 处理 SKU 选择完成后的逻辑 - 只更新商品列表数据
	* 注意：selected 的更新由 skuDetailConfig.onConfirm 处理
	* @return {*}
	*/
	const handleSkuConfirmCallback = (0, react.useCallback)((productId, cacheItem, selected) => {
		const { originProducts } = require_utils$1.updateProductInList({
			products: (productsRef === null || productsRef === void 0 ? void 0 : productsRef.current) || [],
			productId,
			cacheItem
		});
		setProducts(originProducts || []);
		if (!require_utils$1.isProductNeedSku(cacheItem)) {
			setSelected(selected);
			return;
		}
		handleCustomCallback(cacheItem, "onConfirm");
	}, [currentItem]);
	const { SkuModal } = require_useSkuModal.useSkuModal({ onConfirm: handleSkuConfirmCallback });
	/**
	* @description: 获取商品列表请求
	* @return {*}
	*/
	const getProductsRequest = (0, ahooks.useRequest)(require_server.getProducts, {
		manual: true,
		onSuccess: (res) => {
			setProducts(require_utils$1.transformInitProductLists(res, !!(currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift), currentItem === null || currentItem === void 0 ? void 0 : currentItem._selectedOriginGifts));
		},
		onError: (error) => {
			console.error("getProducts error:", error);
		}
	});
	/**
	* @description: 打开营销弹窗并设置数据源
	* @return {*}
	*/
	const openModal = (0, react.useCallback)((item) => {
		var _item$products;
		setCurrentItem(item || {});
		setSelected(item === null || item === void 0 ? void 0 : item.selected);
		if (item === null || item === void 0 || (_item$products = item.products) === null || _item$products === void 0 ? void 0 : _item$products.length) {
			var _item$state, _item$products2;
			const date = item === null || item === void 0 || (_item$state = item.state) === null || _item$state === void 0 || (_item$state = _item$state.date) === null || _item$state === void 0 || (_item$state = _item$state.value) === null || _item$state === void 0 ? void 0 : _item$state.format("YYYY-MM-DD");
			getProductsRequest.run({
				ids: (item === null || item === void 0 || (_item$products2 = item.products) === null || _item$products2 === void 0 ? void 0 : _item$products2.map((option) => option.product_id)) || [],
				isGift: !!(item === null || item === void 0 ? void 0 : item.isGift),
				schedule_date: date
			});
		}
		setOpen(true);
	}, [getProductsRequest]);
	/**
	* @description: 关闭营销弹窗
	* @param {*} useCallback
	* @return {*}
	*/
	const closeModal = (0, react.useCallback)(() => {
		var _options$onCancel;
		setOpen(false);
		setSelected((currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple) ? [] : "");
		setProducts([]);
		setCurrentItem({});
		options === null || options === void 0 || (_options$onCancel = options.onCancel) === null || _options$onCancel === void 0 || _options$onCancel.call(options);
		productsRef.current = [];
		setCartProducts([]);
	}, [currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple, options === null || options === void 0 ? void 0 : options.onCancel]);
	/**
	* @description: 自定义回调函数
	* @param {*} useMemoizedFn
	* @return {*}
	*/
	const handleCustomCallback = (0, ahooks.useMemoizedFn)((product, type) => {
		if (!require_utils$1.isProductNeedSku(product)) return;
		let newSelected;
		if (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple) {
			newSelected = Array.isArray(selected) ? [...selected] : [];
			const isStepper = newSelected.length > 0 && typeof newSelected[0] === "object" && "value" in newSelected[0];
			if (type === "onConfirm") {
				var _product$_extend;
				const existingIndex = newSelected.findIndex((item) => item.value === (product === null || product === void 0 ? void 0 : product.id));
				const quantity = (product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.quantity) || (product === null || product === void 0 ? void 0 : product.quantity) || 1;
				if (existingIndex >= 0) newSelected[existingIndex] = {
					value: product.id,
					quantity
				};
				else newSelected.push({
					value: product.id,
					quantity
				});
			} else if (isStepper) {
				newSelected = newSelected.filter((item) => item.value !== (product === null || product === void 0 ? void 0 : product.id));
				productsRef.current = productsRef.current.map((p) => {
					if (p.id === (product === null || product === void 0 ? void 0 : product.id)) p._extend.quantity = 1;
					return p;
				});
			} else {
				const index = newSelected.indexOf(product === null || product === void 0 ? void 0 : product.id);
				if (index >= 0) newSelected.splice(index, 1);
			}
		} else if (type === "onConfirm") newSelected = product === null || product === void 0 ? void 0 : product.id;
		else newSelected = "";
		setRandomKey(Math.random());
		setSelected(newSelected);
	});
	const skuDetailConfig = (0, react.useCallback)((product) => {
		let _customData = {};
		if (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift) _customData = {
			price: (product === null || product === void 0 ? void 0 : product.price) || 0,
			base_price: (product === null || product === void 0 ? void 0 : product.base_price) || 0,
			original_price: (product === null || product === void 0 ? void 0 : product.origin_price) || 0
		};
		return {
			isShowStepper: false,
			isShowNote: false,
			externalVariant: {
				isCustom: true,
				formatVariant: (variant) => {
					if (!(currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift)) return variant;
					return require_utils$1.giftVariants(variant);
				}
			},
			useCustomData: true,
			customData: _customData,
			isCallProductDetail: true,
			onConfirm: (data) => {},
			onRemove: (data) => {
				handleCustomCallback(product, "onRemove");
			}
		};
	}, [
		currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift,
		currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple,
		selected
	]);
	/**
	* @description: 处理 SKU 弹窗回调 - 更新选中的商品列表
	* @param {any} data - SKU 弹窗返回的商品数据
	* @param {any} originalProduct - 原始商品数据
	* @param {any} selected - 选中的商品
	*/
	const handleSkuModalCallback = (0, ahooks.useMemoizedFn)((data, originalProduct, selected) => {
		handleSkuConfirmCallback(originalProduct === null || originalProduct === void 0 ? void 0 : originalProduct.id, data, selected);
	});
	/**
	* @description: 准备商品数据
	* @param {any} product - 原始商品数据
	* @return {any} 过滤后的商品数据
	*/
	const prepareProductForSkuModal = (0, ahooks.useMemoizedFn)((product) => {
		return require_utils$1.filterProductByPromotionRules(product, currentItem);
	});
	/**
	* @description: 打开编辑服务弹窗（openNormalService 方式）
	* @param {any} product - 商品数据
	* @param {any} selected - 选中的商品
	*/
	const openEditNormalService = (0, ahooks.useMemoizedFn)((product, selected) => {
		const openNormalService = require_openNormalService.getOpenNormalServiceHandler();
		if (!openNormalService) return;
		openNormalService({
			mode: "edit",
			cacheItem: product,
			skuDetailConfig: skuDetailConfig(product),
			callback: (data) => {
				handleSkuModalCallback(data, product, selected);
			}
		});
	});
	/**
	* @description: 打开添加服务弹窗（getHandleAddService 方式）
	* @param {any} product - 商品数据
	* @param {any} selected - 选中的商品
	*/
	const openAddService = (0, ahooks.useMemoizedFn)((product, selected) => {
		const handleAddService = require_utils.getHandleAddService();
		if (!handleAddService) return;
		handleAddService(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, product), {}, { skuDetailConfig: skuDetailConfig(product) }), (cacheItem) => {
			handleSkuModalCallback(cacheItem, product, selected);
		});
	});
	/**
	* @description: 是否是零售商品
	* @param {*} useCallback
	* @return {*}
	*/
	const isRetail = (0, react.useCallback)((option) => {
		var _option$dataSource;
		return require_utils$2.isNormalProductByDurationSchedule((option === null || option === void 0 || (_option$dataSource = option.dataSource) === null || _option$dataSource === void 0 ? void 0 : _option$dataSource._origin) || (option === null || option === void 0 ? void 0 : option.dataSource) || (option === null || option === void 0 ? void 0 : option._origin));
	}, []);
	/**
	* @description: 是否显示编辑按钮
	* @param {*} useCallback
	* @return {*}
	*/
	const isShowEditBtn = (0, react.useCallback)((option) => {
		var _option$dataSource2;
		return require_utils$1.isProductNeedSku((option === null || option === void 0 || (_option$dataSource2 = option.dataSource) === null || _option$dataSource2 === void 0 ? void 0 : _option$dataSource2._origin) || (option === null || option === void 0 ? void 0 : option.dataSource) || (option === null || option === void 0 ? void 0 : option._origin));
	}, []);
	/**
	* @description: 打开 SKU 弹窗选择规格
	* @param {any} product - 商品数据
	* @param {any} selected - 选中的商品
	*/
	const _openSkuModal = (0, ahooks.useMemoizedFn)(function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* (product, selected) {
			try {
				var _product$_extend2;
				if ((currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple) && Array.isArray(selected)) {
					const isNormal = require_utils$2.isNormalProductByDurationSchedule(product);
					const _productId = (product === null || product === void 0 ? void 0 : product.product_id) || (product === null || product === void 0 ? void 0 : product.id);
					if (!(selected === null || selected === void 0 ? void 0 : selected.some((item) => (item === null || item === void 0 ? void 0 : item.value) === _productId)) && !isNormal) {
						setSelected(selected);
						return;
					}
				}
				let _product = require_utils$1.findProductById(productsRef.current, product === null || product === void 0 ? void 0 : product.id);
				if (!_product) return;
				_product = prepareProductForSkuModal(_product);
				if ((_product === null || _product === void 0 || (_product$_extend2 = _product._extend) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.isNormalProduct) && (_product === null || _product === void 0 ? void 0 : _product.is_eject)) {
					if (require_utils$1.isProductNeedSku(_product) && !(_product === null || _product === void 0 ? void 0 : _product.created_at)) try {
						const { data } = yield require_serve.getProductDetail(String(_product.id), { is_eject: 1 });
						_product.option_group = data === null || data === void 0 ? void 0 : data.option_group;
						_product.bundle_group = data === null || data === void 0 ? void 0 : data.bundle_group;
					} catch (error) {}
					openEditNormalService(_product, selected);
				} else openAddService(_product, selected);
			} catch (error) {
				console.error("openSkuModal error:", error);
			}
		});
		return function(_x, _x2) {
			return _ref.apply(this, arguments);
		};
	}());
	/**
	* @description: 处理商品选择
	* @param {any} value - 点击的商品 ID
	* @return {*}
	*/
	const handleProductSelect = (0, react.useCallback)((value) => {
		if (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple) {
			const newSelectedData = Array.isArray(value) ? value : [];
			const prevSelectedData = Array.isArray(selected) ? selected : [];
			const isStepper = newSelectedData.length > 0 && typeof newSelectedData[0] === "object" && "value" in newSelectedData[0];
			const newSelectedIds = isStepper ? newSelectedData.map((item) => item.value) : newSelectedData;
			const prevSelectedIds = isStepper && prevSelectedData.length > 0 && typeof prevSelectedData[0] === "object" && "value" in prevSelectedData[0] ? prevSelectedData.map((item) => item.value) : prevSelectedData;
			const addedIds = newSelectedIds.filter((id) => !prevSelectedIds.includes(id));
			const removedIds = prevSelectedIds.filter((id) => !newSelectedIds.includes(id));
			if (addedIds.length > 0) {
				const addedId = addedIds[0];
				const selectedProductData = require_utils$1.findProductById(productsRef.current, addedId);
				if (selectedProductData) _openSkuModal(selectedProductData, newSelectedData);
			} else if (removedIds.length > 0) {
				const removedId = removedIds[0];
				const removedProductData = require_utils$1.findProductById(productsRef.current, removedId);
				if (removedProductData === null || removedProductData === void 0 ? void 0 : removedProductData.is_eject) _openSkuModal(removedProductData, newSelectedData);
				else setSelected(newSelectedData);
			} else {
				if (isStepper) {
					var _productsRef$current;
					setProducts(((_productsRef$current = productsRef.current) === null || _productsRef$current === void 0 ? void 0 : _productsRef$current.map((product) => {
						const stepperItem = newSelectedData.find((item) => item.value === product.id);
						if (stepperItem) {
							const _quantity = stepperItem.quantity || 1;
							product._extend.quantity = _quantity;
						}
						return product;
					})) || []);
				}
				setSelected(newSelectedData);
			}
		} else {
			const prevSelected = selected;
			const newSelected = value || "";
			if (newSelected && newSelected !== prevSelected) {
				const selectedProductData = require_utils$1.findProductById(productsRef.current, newSelected);
				if (selectedProductData) _openSkuModal(selectedProductData, newSelected);
			} else if (prevSelected && !newSelected) {
				const prevProductData = require_utils$1.findProductById(productsRef.current, prevSelected);
				if (prevProductData === null || prevProductData === void 0 ? void 0 : prevProductData.is_eject) _openSkuModal(prevProductData, newSelected);
				else setSelected(newSelected);
			} else setSelected(newSelected);
		}
	}, [
		selected,
		currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple,
		products,
		_openSkuModal,
		setSelected
	]);
	/**
	* @description: 确认选择商品
	* @param {*} useCallback
	* @return {*}
	*/
	const handleConfirm = (0, react.useCallback)(() => {
		if (!selected || Array.isArray(selected) && !selected.length) return;
		try {
			var _currentItem$selected, _options$onConfirm;
			const selectedIds = Array.isArray(selected) ? selected.map((item) => (item === null || item === void 0 ? void 0 : item.value) || item) : [selected];
			const _selectedProduct = require_utils$1.findSelectedProductsFromList(productsRef.current, selectedIds);
			if (!(_selectedProduct === null || _selectedProduct === void 0 ? void 0 : _selectedProduct.length)) return;
			const promotionInfo = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.promotionInfo) || {};
			promotionInfo.lastEvaluatedGiftCount = (currentItem === null || currentItem === void 0 || (_currentItem$selected = currentItem.selectedProducts) === null || _currentItem$selected === void 0 || (_currentItem$selected = _currentItem$selected[0]) === null || _currentItem$selected === void 0 || (_currentItem$selected = _currentItem$selected._giftInfo) === null || _currentItem$selected === void 0 ? void 0 : _currentItem$selected.lastEvaluatedGiftCount) || 1;
			let _products = _selectedProduct.map((item) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
				_giftInfo: (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift) ? promotionInfo : null,
				_promotionInfo: (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift) ? null : promotionInfo
			}));
			options === null || options === void 0 || (_options$onConfirm = options.onConfirm) === null || _options$onConfirm === void 0 || _options$onConfirm.call(options, {
				selectedProducts: _products,
				currentItem
			});
			closeModal();
		} catch (error) {
			console.error("Marketing modal confirm error:", error);
		}
	}, [
		products,
		selected,
		currentItem,
		options === null || options === void 0 ? void 0 : options.onConfirm,
		closeModal
	]);
	/**
	* @description: 是否禁用卡片点击事件
	* @return {*}
	*/
	const isDisabledClick = (0, react.useCallback)((option) => {
		if (!isShowEditBtn(option)) return true;
		if (!(currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple)) return true;
		return false;
	}, [currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple]);
	/**
	* @description: 多选模式下点击商品卡片需要的选中数据
	* @return {*}
	*/
	const multipleSelected = (0, react.useCallback)((option) => {
		var _option$dataSource3;
		const item = (option === null || option === void 0 || (_option$dataSource3 = option.dataSource) === null || _option$dataSource3 === void 0 ? void 0 : _option$dataSource3._origin) || (option === null || option === void 0 ? void 0 : option.dataSource);
		const productId = (item === null || item === void 0 ? void 0 : item.product_id) || (item === null || item === void 0 ? void 0 : item.id);
		const isSelected = selected === null || selected === void 0 ? void 0 : selected.some((item) => (item === null || item === void 0 ? void 0 : item.value) === productId);
		return {
			isExist: !!isSelected,
			selectedData: !isSelected ? [{
				value: productId,
				quantity: 1
			}] : selected
		};
	}, [selected]);
	/**
	* @description: 营销弹窗内容
	* @param {*} useMemo
	* @return {*}
	*/
	const modalContent = (0, react.useMemo)(() => {
		if (!open) return null;
		if (getProductsRequest.loading) return /* @__PURE__ */ react.default.createElement(antd.Skeleton, {
			active: true,
			loading: true
		});
		const _mode = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple) ? "multiple" : "single";
		const _maxAvailableCount = require_utils$1.getMaxAvailableCount(currentItem);
		const _title = !(currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift) ? _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.product.tip")(_maxAvailableCount) : _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.tip")(_maxAvailableCount);
		const _showStepper = !!(currentItem === null || currentItem === void 0 ? void 0 : currentItem.isMultiple);
		return /* @__PURE__ */ react.default.createElement("div", { className: `marketing-modal-content marketing-modal-content--${currentVariant}` }, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
			key: randomKey,
			title: _title,
			dataSource: cartProducts || [],
			mode: _mode,
			showStepper: _showStepper,
			stepperProps: {
				size: "middle",
				shape: "round"
			},
			valueType: _showStepper ? "object" : "primitive",
			fieldNames: {
				value: "id",
				label: "title"
			},
			value: selected,
			onChange: handleProductSelect,
			variant: "card",
			preset: { variant: "3" },
			ruleConfig: { max: _maxAvailableCount },
			itemProps: {
				layout: "horizontal",
				renderContent: (option) => {
					var _option$dataSource4, _option$dataSource5;
					return /* @__PURE__ */ react.default.createElement(_pisell_materials.ProductCard.V2, {
						type: isRetail(option) ? "a9" : "a5",
						key: (option === null || option === void 0 || (_option$dataSource4 = option.dataSource) === null || _option$dataSource4 === void 0 ? void 0 : _option$dataSource4._id) || (option === null || option === void 0 || (_option$dataSource5 = option.dataSource) === null || _option$dataSource5 === void 0 ? void 0 : _option$dataSource5.id),
						dataSource: option === null || option === void 0 ? void 0 : option.dataSource,
						isShowImage: true,
						disabledClick: isDisabledClick(option),
						disabledEdit: true,
						onCard: () => {
							const { isExist, selectedData } = multipleSelected(option);
							const _currentMaxProductCount = require_utils$1.getCurrentMaxProductCount(option, selected, currentItem, false);
							if (!isExist && _currentMaxProductCount <= 0) return;
							_openSkuModal(option === null || option === void 0 ? void 0 : option.dataSource, selectedData);
						},
						isShowDelete: false,
						isShowOriginalPrice: true,
						isShowEditProduct: isShowEditBtn(option),
						disabledEditClick: true
					});
				}
			}
		}));
	}, [
		open,
		products,
		cartProducts,
		selected,
		currentItem,
		currentVariant,
		getProductsRequest.loading,
		randomKey,
		isDisabledClick,
		isShowEditBtn,
		multipleSelected
	]);
	return {
		openModal,
		closeModal,
		MarketingModal: (0, react.useMemo)(() => {
			const _title = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift) ? _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.title") : _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.browse.items");
			const confirmDisabled = !selected || Array.isArray(selected) && !(selected === null || selected === void 0 ? void 0 : selected.length);
			const isPhoneVariant = currentVariant === "phone";
			const containerProps = isPhoneVariant ? {
				open,
				title: _title,
				placement: "bottom",
				width: "100%",
				height: "95dvh",
				style: { maxHeight: "95dvh" },
				onClose: closeModal,
				destroyOnClose: true,
				zIndex: 1e3,
				closable: false,
				className: "shopping-cart-marketing-modal shopping-cart-marketing-modal--phone",
				bodyStyle: {
					padding: "0 16px",
					overflow: "auto"
				},
				footer: /* @__PURE__ */ react.default.createElement("div", { className: "shopping-cart-marketing-modal-footer" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
					block: true,
					type: "primary",
					size: "large",
					disabled: confirmDisabled,
					loading,
					onClick: handleConfirm
				}, _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.confirm")))
			} : {
				open,
				width: 660,
				title: _title,
				okText: _pisell_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.confirm"),
				okButtonProps: { disabled: confirmDisabled },
				destroyOnClose: true,
				confirmLoading: loading,
				cancelVisible: false,
				onOk: handleConfirm,
				onCancel: closeModal,
				zIndex: 1e3,
				className: `shopping-cart-marketing-modal shopping-cart-marketing-modal--${currentVariant}`
			};
			return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(require_index.default, {
				renderType: isPhoneVariant ? "drawer" : "modal",
				showHandlerBar: isPhoneVariant,
				onHandlerBarClick: closeModal,
				props: containerProps
			}, modalContent));
		}, [
			open,
			selected,
			loading,
			modalContent,
			handleConfirm,
			closeModal,
			currentItem === null || currentItem === void 0 ? void 0 : currentItem.isGift,
			currentVariant
		]),
		SkuModal,
		selected,
		isOpen: open
	};
};
//#endregion
exports.usePromotionModal = usePromotionModal;
